Chat fixes (#4947)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2024-03-13 22:05:26 +07:00
committed by GitHub
parent 97d03c38ee
commit f2b4176db3
3 changed files with 55 additions and 9 deletions
@@ -258,9 +258,14 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
try {
const inboxNotifications = get(this.inboxNotifications) ?? []
const contexts = get(this.docNotifyContexts) ?? []
for (const notification of inboxNotifications) {
await ops.remove(notification)
}
for (const context of contexts) {
await ops.update(context, { lastViewedTimestamp: Date.now() })
}
} finally {
await ops.commit()
await doneOp()
@@ -273,11 +278,15 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
try {
const inboxNotifications = get(this.inboxNotifications) ?? []
const contexts = get(this.docNotifyContexts) ?? []
for (const notification of inboxNotifications) {
if (!notification.isViewed) {
await ops.update(notification, { isViewed: true })
}
}
for (const context of contexts) {
await ops.update(context, { lastViewedTimestamp: Date.now() })
}
} finally {
await ops.commit()
await doneOp()
@@ -290,11 +299,16 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
try {
const inboxNotifications = get(this.inboxNotifications) ?? []
const contexts = get(this.docNotifyContexts) ?? []
for (const notification of inboxNotifications) {
if (notification.isViewed) {
await ops.update(notification, { isViewed: false })
}
}
for (const context of contexts) {
await ops.update(context, { lastViewedTimestamp: 0 })
}
} finally {
await ops.commit()
await doneOp()