Files
1f0bb86c3f FEATURE: Add ability to watch chat threads (#28639)
This change introduces a new thread notification level allowing users to get notified when someone replies to the thread.

Users who watch a thread will get a green notification on the chat icon and a user notification (blue). User notifications are consolidated based on thread id to prevent cluttering the original users notification area.

---------

Co-authored-by: Régis Hanol <[email protected]>
2024-09-02 16:45:55 +04:00

61 lines
1.5 KiB
JavaScript

import { tracked } from "@glimmer/tracking";
import { setOwner } from "@ember/owner";
import { service } from "@ember/service";
export default class ChatTrackingState {
@service chatTrackingStateManager;
@tracked _unreadCount;
@tracked _mentionCount;
@tracked _watchedThreadsUnreadCount;
constructor(owner, params = {}) {
setOwner(this, owner);
this._unreadCount = params.unreadCount ?? 0;
this._mentionCount = params.mentionCount ?? 0;
this._watchedThreadsUnreadCount = params.watchedThreadsUnreadCount ?? 0;
}
reset() {
this._unreadCount = 0;
this._mentionCount = 0;
this._watchedThreadsUnreadCount = 0;
}
get unreadCount() {
return this._unreadCount;
}
set unreadCount(value) {
const valueChanged = this._unreadCount !== value;
if (valueChanged) {
this._unreadCount = value;
this.chatTrackingStateManager.triggerNotificationsChanged();
}
}
get mentionCount() {
return this._mentionCount;
}
set mentionCount(value) {
const valueChanged = this._mentionCount !== value;
if (valueChanged) {
this._mentionCount = value;
this.chatTrackingStateManager.triggerNotificationsChanged();
}
}
get watchedThreadsUnreadCount() {
return this._watchedThreadsUnreadCount;
}
set watchedThreadsUnreadCount(value) {
const valueChanged = this._watchedThreadsUnreadCount !== value;
if (valueChanged) {
this._watchedThreadsUnreadCount = value;
this.chatTrackingStateManager.triggerNotificationsChanged();
}
}
}