diff --git a/js/languages/en_US.json b/js/languages/en_US.json index fdcf39202..82e2b1060 100644 --- a/js/languages/en_US.json +++ b/js/languages/en_US.json @@ -1517,20 +1517,20 @@ "moderatorsLoaded": "%{total} moderator loaded |||| %{total} moderators loaded.", "noModsMsg": { "noModerators": { - "title": "No Valid Moderators Are Available.", - "body": "None of the loaded moderators are valid. This order will be a direct payment." + "title": "No valid moderators have been loaded.", + "body": "This order will be a direct payment." }, "noVerifiedModerators": { - "title": "No Verified Moderators Available", + "title": "No verified moderators have been loaded.", "body": "Try viewing unverified moderators." }, "noMatchingModerators": { - "title": "No moderators that accept %{coin} are available.", + "title": "No moderators that accept %{coin} have been loaded.", "body": "Moderators are available on one or more of the other currencies accepted by this listing." }, "noMatchingVerifiedModerators": { "title": "No verified moderators that accept %{coin} have been loaded.", - "body": "Try viewing unverified moderators." + "body": "Try viewing unverified moderators or using another currency." } }, "showUnverified": "Show Unverified Moderators", @@ -5740,4 +5740,4 @@ "zu": "Zulu", "zu-ZA": "Zulu (South Africa)" } -} \ No newline at end of file +} diff --git a/js/templates/components/moderators/moderators.html b/js/templates/components/moderators/moderators.html index 5137ae87b..3f478c37d 100644 --- a/js/templates/components/moderators/moderators.html +++ b/js/templates/components/moderators/moderators.html @@ -1,12 +1,5 @@
- <% // placeholder so border collapse doesn't erase the table border when there are no table cells %> - <% if (ob.placeholder) { %> -
-
-
-
- <% } %> - <% if (ob.totalIDs && !ob.totalShown) { %> + <% if (!ob.totalShown) { %>
@@ -15,10 +8,12 @@ const showOnlyCur = ob.showOnlyCur ? 'Matching' : ''; const opts = ob.showOnlyCur ? { coin: ob.showOnlyCur } : {}; const msgPath = `moderators.noModsMsg.no${showOnlyCur}${showOnlyVer}Moderators`; + const title = ob.loading ? + ob.polyT('moderators.moderatorsLoading') : ob.polyT(`${msgPath}.title`, opts); %> -

<%= ob.polyT(`${msgPath}.title`, opts) %>

+

<%= title %>

<% // The section below is only relevant if the moderators are loaded in a purchasing context. %> - <% if (ob.purchase) { %> + <% if (ob.purchase && !ob.loading) { %>
<%= ob.polyT(`${msgPath}.body`) %>
<% if (showOnlyVer) { %>
<% // just a spacer %>
diff --git a/js/templates/components/moderators/status.html b/js/templates/components/moderators/status.html index 98a9d476a..5d8581e32 100644 --- a/js/templates/components/moderators/status.html +++ b/js/templates/components/moderators/status.html @@ -2,7 +2,7 @@ <% if (ob.showSpinner && ob.loading) { %> <%= ob.spinner({ className: 'spinnerTxt js-spinner' }) %> <% } %> - + <% if (ob.mode === 'loaded') { print(ob.polyT('moderators.moderatorsLoaded', { total: ob.total, smart_count: ob.total })); } else if (ob.mode === 'loadingXofY') { diff --git a/js/views/components/moderators/Moderators.js b/js/views/components/moderators/Moderators.js index 5ab732937..b77a1eaac 100644 --- a/js/views/components/moderators/Moderators.js +++ b/js/views/components/moderators/Moderators.js @@ -93,9 +93,9 @@ export default class extends baseVw { super(opts); this.options = opts; - this.excludeIDs = opts.excludeIDs; + this.excludeIDs = [...opts.excludeIDs, app.profile.id]; + this.modsToFetch = [...opts.moderatorIDs]; this.unfetchedMods = []; - this.fetchingMods = []; this.fetchingVerifiedMods = []; this.modFetches = []; this.moderatorsCol = new Moderators(); @@ -172,37 +172,36 @@ export default class extends baseVw { throw new Error('Please provide the list of moderators as an array.'); } - // don't get any that have already been added or excluded, or the user's own id. - const excluded = [app.profile.id, ...this.allIDs, ...this.excludeIDs]; - const IDs = _.without(op.moderatorIDs, excluded); const includeString = op.include ? `&include=${op.include}` : ''; const urlString = `ob/${op.apiPath}?async=${op.async}${includeString}&usecache=${op.useCache}`; const url = app.getServerUrl(urlString); - this.unfetchedMods = IDs; - this.fetchingMods = IDs; - this.fetchingVerifiedMods = app.verifiedMods.matched(IDs); - - this.setState({ - loading: true, - noValidModerators: false, - noValidVerifiedModerators: !this.fetchingVerifiedMods.length, - }); + // don't get any that have already been added or excluded. + const excluded = [...this.allIDs, ...this.excludeIDs]; + this.modsToFetch = _.without(op.moderatorIDs, excluded); + this.unfetchedMods = [...this.modsToFetch]; + this.fetchingVerifiedMods = app.verifiedMods.matched(this.modsToFetch); // Either a list of IDs can be posted, or any available moderators can be retrieved with GET - if (IDs.length || op.method === 'GET') { + if (this.modsToFetch.length || op.method === 'GET') { + this.setState({ + loading: true, + noValidModerators: false, + noValidVerifiedModerators: !this.fetchingVerifiedMods.length, + }); + this.moderatorsStatus.setState({ hidden: false, loaded: 0, - toLoad: IDs.length, + toLoad: this.modsToFetch.length, total: this.modCount, loading: true, }); const fetch = $.ajax({ url, - data: JSON.stringify(IDs), + data: JSON.stringify(this.modsToFetch), method: op.method, }) .done((data) => { @@ -213,13 +212,15 @@ export default class extends baseVw { const eventData = event.jsonData; if (eventData.error) { // errors don't have a message id, check to see if the peerID matches - if (IDs.includes(eventData.peerId)) { - // provide the expected capitalization of peerID - eventData.peerID = eventData.peerId; - delete eventData.peerId; + if (this.modsToFetch.includes(eventData.peerID)) { this.processMod(eventData); } - } else if (eventData.id === socketID && !excluded.includes(eventData.peerId)) { + } else if ( + eventData.id && + eventData.peerId && + eventData.id === socketID && + !excluded.includes(eventData.peerId) + ) { this.processMod(eventData.profile); } }); @@ -230,9 +231,7 @@ export default class extends baseVw { data.forEach(mod => { if (!excluded.includes(mod.peerId)) this.processMod(mod.profile); }); - this.unfetchedMods = []; - this.checkNotFetched(); - if (!data.length) this.trigger('noModsFound', { guids: IDs }); + if (!data.length) this.trigger('noModsFound', { guids: this.modsToFetch }); } }) .fail((xhr) => { @@ -259,7 +258,7 @@ export default class extends baseVw { } checkNotFetched() { - if (this.unfetchedMods.length === 0 && this.fetchingMods.length) { + if (this.unfetchedMods.length === 0) { // All ids have been fetched and ids existed to fetch. this.moderatorsStatus.setState({ loading: false, @@ -272,7 +271,7 @@ export default class extends baseVw { // Either ids are still fetching, or this is an open fetch with no set ids. this.moderatorsStatus.setState({ loaded: this.moderatorsCol.length, // not shown if open fetch - toLoad: this.fetchingMods.length, // not shown if open fetch + toLoad: this.modsToFetch.length, // not shown if open fetch total: this.modCount, }); // re-render to show the unverified moderators button if needed. @@ -403,19 +402,16 @@ export default class extends baseVw { render() { const state = this.getState(); const showMods = this.modCards.filter(mod => this.modShouldRender(mod.model)); - const unVerCount = this.modCards.filter(mod => - mod.model.hasModCurrency(state.showOnlyCur) && !mod.model.isVerified).length; - const totalIDs = this.allIDs.length; + const unVerCount = this.modCards.filter(mod => (!state.showOnlyCur || + mod.model.hasModCurrency(state.showOnlyCur)) && !mod.model.isVerified).length; clearTimeout(this.renderTimer); this.renderTimer = null; loadTemplate('components/moderators/moderators.html', t => { this.$el.html(t({ wrapperClasses: this.options.wrapperClasses, - placeholder: !showMods.length && (this.unfetchedMods.length || !totalIDs), purchase: this.options.purchase, totalShown: showMods.length, - totalIDs, unVerCount, ...state, })); diff --git a/js/views/components/moderators/Status.js b/js/views/components/moderators/Status.js index 32f577e8c..109556768 100644 --- a/js/views/components/moderators/Status.js +++ b/js/views/components/moderators/Status.js @@ -38,7 +38,7 @@ export default class extends BaseVw { let mode = this.getState().mode; if (mode === 'loadingXofY') mode = 'loadingXofYTimedOut'; this.setState({ showSpinner: false, mode }); - }, 10000); + }, 60000); } super.setState(state, options); } diff --git a/js/views/modals/Settings/Store.js b/js/views/modals/Settings/Store.js index f813700cd..672271468 100644 --- a/js/views/modals/Settings/Store.js +++ b/js/views/modals/Settings/Store.js @@ -286,22 +286,11 @@ export default class extends baseVw { const remAvail = this.modsAvailable.removeModeratorsByID(this.modsAvailable.selectedIDs); this.modsByID.excludeIDs = this.currentMods; - this.modsByID.moderatorsStatus.setState({ - hidden: true, - }); this.modsSelected.moderatorsCol.add([...remByID, ...remAvail]); - this.modsSelected.moderatorsStatus.setState({ - hidden: true, - }); this.modsAvailable.excludeIDs = this.currentMods; this.modsAvailable.moderatorsCol.add(remSel); - this.modsAvailable.moderatorsStatus.setState({ - hidden: false, - total: this.modsAvailable.modCount, - showSpinner: false, - }); // If any of the mods moved to the available collect are unverified, show them if (app.verifiedMods.matched(unSel).length !== unSel.length) { diff --git a/js/views/modals/purchase/Purchase.js b/js/views/modals/purchase/Purchase.js index 8e04f485b..3f762f48c 100644 --- a/js/views/modals/purchase/Purchase.js +++ b/js/views/modals/purchase/Purchase.js @@ -162,7 +162,7 @@ export default class extends BaseModal { singleSelect: true, radioStyle: true, initialState: { - showOnlyCur: currencies[0], + showOnlyCur: '', showVerifiedOnly: true, }, });