Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Don't show moderators that have the wrong currency #764

Merged
merged 2 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion js/collections/Moderators.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ export default class extends Collection {
// don't add excluded ids or your own id
const notExcluded = excludeList.indexOf(mod.id) === -1 && mod.id !== app.profile.id;
// don't add if not a mod or the mod data is missing
// don't add if the currency doesn't match the network
const cur = app.serverConfig.cryptoCurrency;
const validCur = mod.get('moderatorInfo').get('acceptedCurrencies').indexOf(cur) > -1;
if (!mod.isModerator) this.trigger('invalidMod', { id: mod.id });
return mod.isModerator && notExcluded;
return mod.isModerator && notExcluded && validCur;
});
}
return super.add(filteredModels, options);
Expand Down
11 changes: 10 additions & 1 deletion js/views/modals/purchase/Moderators.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,16 @@ export default class extends baseVw {
// don't add profiles that are not moderators. The ID list may have peerIDs
// that are out of date, and are no longer moderators.
if (eventData.profile.moderator && eventData.profile.moderatorInfo) {
this.moderatorsCol.add(eventData.profile);
// if the moderator has an invalid currency, remove them from the list
const buyerCur = app.serverConfig.cryptoCurrency;
const modCurs = eventData.profile.moderatorInfo.acceptedCurrencies;
const validCur = modCurs.indexOf(buyerCur) > -1;
if (validCur) {
this.moderatorsCol.add(eventData.profile);
} else {
// remove the invalid moderator from the notFetched list
this.removeNotFetched(eventData.peerId);
}
} else {
// remove the invalid moderator from the notFetched list
this.removeNotFetched(eventData.peerId);
Expand Down