Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 8d65d44

Browse files
committed
Prevent Duplicate Moderators in Store Wizard
- doesn't render duplicate guids in the moderator list of the store wizard. - also checks any moderators the user has already added if they have turned their store off in settings, and are reactivating it here.
1 parent 24022b6 commit 8d65d44

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

js/views/storeWizardVw.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = baseModal.extend({
3030
if (this.model.get('page').profile.header_hash){
3131
this.model.set('headerURL', this.model.get('user').serverUrl+"get_image?hash="+this.model.get('page').profile.header_hash);
3232
}
33+
this.existingMods = this.model.get('user').moderator_guids;
3334

3435
this.listenTo(window.obEventBus, "socketMessageReceived", function(response){
3536
this.handleSocketMessage(response);
@@ -90,6 +91,7 @@ module.exports = baseModal.extend({
9091

9192
render: function() {
9293
var self = this;
94+
this.shownMods = []; //reset to blank
9395

9496
loadTemplate('./js/templates/storeWizard.html', function(loadedTemplate) {
9597
self.$el.html(loadedTemplate(self.model.toJSON()));
@@ -148,12 +150,19 @@ module.exports = baseModal.extend({
148150
},
149151

150152
renderModerator: function(moderator){
153+
//make sure this moderator is not a duplicate
154+
if (this.shownMods.indexOf(moderator.guid) > -1){
155+
return;
156+
}
157+
this.shownMods.push(moderator.guid);
158+
151159
moderator.serverUrl = this.model.get('user').serverUrl;
152160
moderator.userID = moderator.guid;
153161
moderator.avatarURL = this.model.get('user').serverUrl + "get_image?hash=" + moderator.avatar_hash + "&guid=" + moderator.guid;
154162
moderator.isModerator = true; //flag for template
155163
moderator.micro = true; //flag for template
156164
moderator.userCount = this.moderatorCount;
165+
moderator.existingModerator = this.existingMods.indexOf(moderator.guid) > -1;
157166
var newModModel = new userShortModel(moderator);
158167
var modShort = new userShortView({model: newModModel});
159168

0 commit comments

Comments
 (0)