mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 13:05:08 +02:00
UBERF-8547: Inbox cleanup and other (#7058)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
@@ -148,13 +148,15 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
return InboxNotificationsClientImpl._instance
|
||||
}
|
||||
|
||||
async readDoc (client: TxOperations, _id: Ref<Doc>): Promise<void> {
|
||||
async readDoc (_id: Ref<Doc>): Promise<void> {
|
||||
const docNotifyContext = this._contextByDoc.get(_id)
|
||||
|
||||
if (docNotifyContext === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
const client = getClient()
|
||||
const op = client.apply(undefined, 'readDoc', true)
|
||||
const inboxNotifications = await client.findAll(
|
||||
notification.class.InboxNotification,
|
||||
{ docNotifyContext: docNotifyContext._id, isViewed: false },
|
||||
@@ -162,19 +164,20 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
)
|
||||
|
||||
for (const notification of inboxNotifications) {
|
||||
await client.updateDoc(notification._class, notification.space, notification._id, { isViewed: true })
|
||||
await op.updateDoc(notification._class, notification.space, notification._id, { isViewed: true })
|
||||
}
|
||||
await client.update(docNotifyContext, { lastViewedTimestamp: Date.now() })
|
||||
await op.update(docNotifyContext, { lastViewedTimestamp: Date.now() })
|
||||
}
|
||||
|
||||
async forceReadDoc (client: TxOperations, _id: Ref<Doc>, _class: Ref<Class<Doc>>): Promise<void> {
|
||||
async forceReadDoc (_id: Ref<Doc>, _class: Ref<Class<Doc>>): Promise<void> {
|
||||
const context = this._contextByDoc.get(_id)
|
||||
|
||||
if (context !== undefined) {
|
||||
await this.readDoc(client, _id)
|
||||
await this.readDoc(_id)
|
||||
return
|
||||
}
|
||||
|
||||
const client = getClient()
|
||||
const doc = await client.findOne(_class, { _id })
|
||||
|
||||
if (doc === undefined) {
|
||||
@@ -230,7 +233,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
async archiveNotifications (client: TxOperations, ids: Array<Ref<InboxNotification>>): Promise<void> {
|
||||
const inboxNotifications = (get(this.inboxNotifications) ?? []).filter(({ _id }) => ids.includes(_id))
|
||||
for (const notification of inboxNotifications) {
|
||||
await client.update(notification, { archived: true })
|
||||
await client.update(notification, { archived: true, isViewed: true })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +251,10 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
)
|
||||
const contexts = get(this.contexts) ?? []
|
||||
for (const notification of inboxNotifications) {
|
||||
await ops.updateDoc(notification._class, notification.space, notification._id, { archived: true })
|
||||
await ops.updateDoc(notification._class, notification.space, notification._id, {
|
||||
archived: true,
|
||||
isViewed: true
|
||||
})
|
||||
}
|
||||
|
||||
for (const context of contexts) {
|
||||
|
||||
Reference in New Issue
Block a user