Only show unique badge titles in the Badge Title dropdown

Filter the preference Badge Title to only show unique badge title names.
Updated to use lodash
https://meta.discourse.org/t/set-title-dialog-shows-multiple-instances-of-the-same-badge/19071
This commit is contained in:
cpradio 2014-08-19 21:30:36 -04:00
parent 04cd3c0551
commit 765b099513

View File

@ -19,9 +19,8 @@ export default Ember.ArrayController.extend({
}.property('saving'),
selectableUserBadges: function() {
var items = new Array();
this.get('model').filterBy('badge.allow_title', true).forEach(function(item, index, arr) {
if(!items.findBy('badge.name', item.badge.name)) items.push(item); });
var items = this.get('model').filterBy('badge.allow_title', true);
items = _.uniq(items, true, function(e) { return e.get('badge.name'); });
items.unshiftObject(Em.Object.create({
badge: Discourse.Badge.create({name: I18n.t('badges.no_title')})
}));