mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FIX: correctly handle subscriptions (#24270)
Subscriptions manager have been a pain since the beginning, one of the problem is that thread and channels behave mostly the same but with various small difference which I expect to increase over time. Trying to use subclasses for this case has proven to be a mistake, this commit now uses a class for each case (channel, thread) which for now contains a lot of duplication, which might be reduced in the future but has the merit to make reasoning about each case very simple. This refactor is fixing a bug introduced in90efdd7f9d
which was causing the wrong channel to be unsubscribed, this shouldn't be possible anymore. We had tests for this which were disabled due to flakeyness, I will consider re-enabling them in the future. Other notes: - notices had been added to the subscriptions manager service, they have been moved into their own dedicated service: `ChatChannelNoticesManager` - the `(each model)` trick used in `<ChatChannel />` since90efdd7f9d
to ensure atomicity has been applied to `<ChatThread />` too
This commit is contained in:
@ -12,9 +12,7 @@ module("Discourse Chat | Component | chat-notice", function (hooks) {
|
||||
|
||||
test("displays all notices for a channel", async function (assert) {
|
||||
this.channel = fabricators.channel();
|
||||
this.manager = this.container.lookup(
|
||||
"service:chatChannelPaneSubscriptionsManager"
|
||||
);
|
||||
this.manager = this.container.lookup("service:chatChannelNoticesManager");
|
||||
this.manager.handleNotice({
|
||||
channel_id: this.channel.id,
|
||||
text_content: "hello",
|
||||
@ -40,9 +38,7 @@ module("Discourse Chat | Component | chat-notice", function (hooks) {
|
||||
|
||||
test("Notices can be cleared", async function (assert) {
|
||||
this.channel = fabricators.channel();
|
||||
this.manager = this.container.lookup(
|
||||
"service:chatChannelPaneSubscriptionsManager"
|
||||
);
|
||||
this.manager = this.container.lookup("service:chatChannelNoticesManager");
|
||||
this.manager.handleNotice({
|
||||
channel_id: this.channel.id,
|
||||
text_content: "hello",
|
||||
@ -66,9 +62,7 @@ module("Discourse Chat | Component | chat-notice", function (hooks) {
|
||||
});
|
||||
test("MentionWithoutMembership notice renders", async function (assert) {
|
||||
this.channel = fabricators.channel();
|
||||
this.manager = this.container.lookup(
|
||||
"service:chatChannelPaneSubscriptionsManager"
|
||||
);
|
||||
this.manager = this.container.lookup("service:chatChannelNoticesManager");
|
||||
const text = "Joffrey can't chat, hermano";
|
||||
this.manager.handleNotice({
|
||||
channel_id: this.channel.id,
|
||||
|
Reference in New Issue
Block a user