Hook threads notification state to UI (#7298)
This commit is contained in:
parent
55eda7314b
commit
ce570ab827
6 changed files with 139 additions and 28 deletions
|
@ -40,20 +40,26 @@ export class ThreadNotificationState extends NotificationState implements IDestr
|
|||
this.thread.off(ThreadEvent.ViewThread, this.resetThreadNotification);
|
||||
}
|
||||
|
||||
private handleNewThreadReply(thread: Thread, event: MatrixEvent) {
|
||||
private handleNewThreadReply = (thread: Thread, event: MatrixEvent) => {
|
||||
const client = MatrixClientPeg.get();
|
||||
|
||||
const isOwn = client.getUserId() === event.getSender();
|
||||
if (!isOwn) {
|
||||
const myUserId = client.getUserId();
|
||||
|
||||
const isOwn = myUserId === event.getSender();
|
||||
const readReceipt = this.room.getReadReceiptForUserId(myUserId);
|
||||
|
||||
if (!isOwn && !readReceipt || event.getTs() >= readReceipt.data.ts) {
|
||||
const actions = client.getPushActionsForEvent(event, true);
|
||||
|
||||
const color = !!actions.tweaks.highlight
|
||||
? NotificationColor.Red
|
||||
: NotificationColor.Grey;
|
||||
if (actions?.tweaks) {
|
||||
const color = !!actions.tweaks.highlight
|
||||
? NotificationColor.Red
|
||||
: NotificationColor.Grey;
|
||||
|
||||
this.updateNotificationState(color);
|
||||
this.updateNotificationState(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private resetThreadNotification = (): void => {
|
||||
this.updateNotificationState(NotificationColor.None);
|
||||
|
|
|
@ -23,7 +23,7 @@ import { ThreadNotificationState } from "./ThreadNotificationState";
|
|||
import { NotificationColor } from "./NotificationColor";
|
||||
|
||||
export class ThreadsRoomNotificationState extends NotificationState implements IDestroyable {
|
||||
private threadsState = new Map<Thread, ThreadNotificationState>();
|
||||
public readonly threadsState = new Map<Thread, ThreadNotificationState>();
|
||||
|
||||
protected _symbol = null;
|
||||
protected _count = 0;
|
||||
|
@ -31,6 +31,11 @@ export class ThreadsRoomNotificationState extends NotificationState implements I
|
|||
|
||||
constructor(public readonly room: Room) {
|
||||
super();
|
||||
if (this.room?.threads) {
|
||||
for (const [, thread] of this.room.threads) {
|
||||
this.onNewThread(thread);
|
||||
}
|
||||
}
|
||||
this.room.on(ThreadEvent.New, this.onNewThread);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue