mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 07:30:16 +08:00
FIX: correct various mistakes in chat-notification-manager (#20050)
* FIX: correct various mistakes in chat-notification-manager - The code was still handling global chat through its own variable instead of relying on `ChatStateManager` - There was a typo were the code was using `this` instead of `opts` Note notifications are a future big work of this year and this should be heavily reworked and tested. * linting
This commit is contained in:
parent
23a74ecf8f
commit
939c2a7371
|
@ -11,8 +11,8 @@ import { bind, observes } from "discourse-common/utils/decorators";
|
|||
export default class ChatNotificationManager extends Service {
|
||||
@service presence;
|
||||
@service chat;
|
||||
@service chatStateManager;
|
||||
|
||||
_inChat = false;
|
||||
_subscribedToCore = true;
|
||||
_subscribedToChat = false;
|
||||
_countChatInDocTitle = true;
|
||||
|
@ -56,9 +56,8 @@ export default class ChatNotificationManager extends Service {
|
|||
}
|
||||
|
||||
@bind
|
||||
_pageChanged(path) {
|
||||
this.set("_inChat", path.startsWith("/chat/c/"));
|
||||
if (this._inChat) {
|
||||
_pageChanged() {
|
||||
if (this.chatStateManager.isActive) {
|
||||
this._chatPresenceChannel.enter({ onlyWhileActive: false });
|
||||
this._corePresenceChannel.leave();
|
||||
} else {
|
||||
|
@ -85,7 +84,7 @@ export default class ChatNotificationManager extends Service {
|
|||
this._chatPresenceChannel.count > 0 &&
|
||||
this._corePresenceChannel.count > 0;
|
||||
if (oneTabForEachOpen) {
|
||||
this._inChat
|
||||
this.chatStateManager.isActive
|
||||
? this._subscribeToChat({ only: true })
|
||||
: this._subscribeToCore({ only: true });
|
||||
} else {
|
||||
|
@ -119,7 +118,7 @@ export default class ChatNotificationManager extends Service {
|
|||
this.messageBus.subscribe(this._coreAlertChannel(), this.onMessage);
|
||||
}
|
||||
|
||||
if (this.only && this._subscribedToChat) {
|
||||
if (opts.only && this._subscribedToChat) {
|
||||
this.messageBus.unsubscribe(this._chatAlertChannel(), this.onMessage);
|
||||
this.set("_subscribedToChat", false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user