From dc320c897a3812d96fb0997ba0fb9d3e14444867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 11 May 2022 11:08:50 -0400 Subject: [PATCH] feat: closes #10601, ability to prevent alerts on topic list --- public/src/modules/topicList.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/public/src/modules/topicList.js b/public/src/modules/topicList.js index 1ce4016364..bf4532346e 100644 --- a/public/src/modules/topicList.js +++ b/public/src/modules/topicList.js @@ -101,15 +101,18 @@ define('topicList', [ const category = d.template.category && parseInt(d.cid, 10) !== parseInt(data.cid, 10); - if (categories || filterWatched || category || scheduledTopics.includes(data.tid)) { - return; - } + const preventAlert = !!(categories || filterWatched || category || scheduledTopics.includes(data.tid)); + hooks.fire('filter:topicList.onNewTopic', { topic: data, preventAlert }).then((result) => { + if (result.preventAlert) { + return; + } - if (data.scheduled && data.tid) { - scheduledTopics.push(data.tid); - } - newTopicCount += 1; - updateAlertText(); + if (data.scheduled && data.tid) { + scheduledTopics.push(data.tid); + } + newTopicCount += 1; + updateAlertText(); + }); } function onNewPost(data) { @@ -132,12 +135,15 @@ define('topicList', [ const category = d.template.category && parseInt(d.cid, 10) !== parseInt(post.topic.cid, 10); - if (isMain || categories || filterNew || filterWatched || category) { - return; - } + const preventAlert = !!(isMain || categories || filterNew || filterWatched || category); + hooks.fire('filter:topicList.onNewPost', { post, preventAlert }).then((result) => { + if (result.preventAlert) { + return; + } - newPostCount += 1; - updateAlertText(); + newPostCount += 1; + updateAlertText(); + }); } function updateAlertText() {