Node.js based forum software built for the modern web
fix: only show email confirmation warning toast on pages that it applies
Julian Lam1bd1cc74a411
diff --git a/public/src/app.js b/public/src/app.jsindex a76d4b7f1a..43fb017373 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -97,7 +97,6 @@ app.cacheBuster = null;});createHeaderTooltips();- app.showEmailConfirmWarning();app.showCookieWarning();registerServiceWorker();@@ -740,7 +739,24 @@ app.cacheBuster = null;app.showEmailConfirmWarning = async (err) => {const storage = await app.require('storage');- if (!app.user.uid || parseInt(storage.getItem('email-confirm-dismiss'), 10) === 1) {+ let showModal = false;+ switch (ajaxify.data.template.name) {+ case 'recent': {+ showModal = !ajaxify.data.canPost;+ break;+ }++ case 'category': {+ showModal = !ajaxify.data.privileges['topics:create'];+ break;+ }++ case 'topic': {+ showModal = !ajaxify.data.privileges['topics:reply'];+ }+ }++ if (!showModal || !app.user.uid || parseInt(storage.getItem('email-confirm-dismiss'), 10) === 1) {return;}var msg = {@@ -758,7 +774,6 @@ app.cacheBuster = null;app.removeAlert('email_confirm');ajaxify.go('user/' + app.user.userslug + '/edit/email');};- app.alert(msg);} else if (!app.user['email:confirmed'] && !app.user.isEmailConfirmSent) {msg.message = err ? err.message : '[[error:email-not-confirmed]]';msg.clickfn = function () {@@ -770,12 +785,11 @@ app.cacheBuster = null;app.alertSuccess('[[notifications:email-confirm-sent]]');});};-- app.alert(msg);} else if (!app.user['email:confirmed'] && app.user.isEmailConfirmSent) {msg.message = '[[error:email-not-confirmed-email-sent]]';- app.alert(msg);}++ app.alert(msg);};app.parseAndTranslate = function (template, blockName, data, callback) {diff --git a/public/src/client/category.js b/public/src/client/category.jsindex 62fbc49516..43c828a4af 100644--- a/public/src/client/category.js+++ b/public/src/client/category.js@@ -48,6 +48,8 @@ define('forum/category', [},});+ app.showEmailConfirmWarning();+hooks.fire('action:topics.loaded', { topics: ajaxify.data.topics });hooks.fire('action:category.loaded', { cid: ajaxify.data.cid });};diff --git a/public/src/client/recent.js b/public/src/client/recent.jsindex 35f886c582..93e3593039 100644--- a/public/src/client/recent.js+++ b/public/src/client/recent.js@@ -7,6 +7,7 @@ define('forum/recent', ['topicList'], function (topicList) {app.enterRoom('recent_topics');topicList.init('recent');+ app.showEmailConfirmWarning();};return Recent;diff --git a/public/src/client/topic.js b/public/src/client/topic.jsindex c6cce374c9..adf46848e5 100644--- a/public/src/client/topic.js+++ b/public/src/client/topic.js@@ -74,6 +74,7 @@ define('forum/topic', [$(window).on('scroll', updateTopicTitle);handleTopicSearch();+ app.showEmailConfirmWarning();hooks.fire('action:topic.loaded', ajaxify.data);};