fix: only show email confirmation warning toast on pages that it applies

isekai-main
Julian Lam 3 years ago
parent 2d1380ddf1
commit 1bd1cc74a4

@ -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) {

@ -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 });
};

@ -7,6 +7,7 @@ define('forum/recent', ['topicList'], function (topicList) {
app.enterRoom('recent_topics');
topicList.init('recent');
app.showEmailConfirmWarning();
};
return Recent;

@ -74,6 +74,7 @@ define('forum/topic', [
$(window).on('scroll', updateTopicTitle);
handleTopicSearch();
app.showEmailConfirmWarning();
hooks.fire('action:topic.loaded', ajaxify.data);
};

Loading…
Cancel
Save