mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: don't display new/unread notification for muted topics (#9482)
* FEATURE: don't display new/unread notification for muted topics Currently, even if user mute topic, when a new reply to that topic arrives, the user will get "See 1 new or updated topic" message. After clicking on that link, nothing is visible (because the topic is muted) To solve that problem, we will send background message to all users who recently muted that topic that update is coming and they can ignore the next message about that topic.
This commit is contained in:

committed by
GitHub

parent
54ec9f7009
commit
52c1d7337e
@ -2,8 +2,17 @@ import TopicTrackingState from "discourse/models/topic-tracking-state";
|
||||
import createStore from "helpers/create-store";
|
||||
import Category from "discourse/models/category";
|
||||
import { NotificationLevels } from "discourse/lib/notification-levels";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
QUnit.module("model:topic-tracking-state");
|
||||
QUnit.module("model:topic-tracking-state", {
|
||||
beforeEach() {
|
||||
this.clock = sinon.useFakeTimers(new Date(2012, 11, 31, 12, 0).getTime());
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
this.clock.restore();
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("sync", function(assert) {
|
||||
const state = TopicTrackingState.create();
|
||||
@ -168,3 +177,22 @@ QUnit.test("countNew", assert => {
|
||||
assert.equal(state.countNew(2), 2);
|
||||
assert.equal(state.countNew(3), 1);
|
||||
});
|
||||
|
||||
QUnit.test("mute topic", function(assert) {
|
||||
let currentUser = User.create({
|
||||
username: "chuck",
|
||||
muted_category_ids: []
|
||||
});
|
||||
|
||||
const state = TopicTrackingState.create({ currentUser });
|
||||
|
||||
state.trackMutedTopic(1);
|
||||
assert.equal(currentUser.muted_topics[0].topicId, 1);
|
||||
|
||||
state.pruneOldMutedTopics();
|
||||
assert.equal(state.isMutedTopic(1), true);
|
||||
|
||||
this.clock.tick(60000);
|
||||
state.pruneOldMutedTopics();
|
||||
assert.equal(state.isMutedTopic(1), false);
|
||||
});
|
||||
|
Reference in New Issue
Block a user