mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 08:57:14 +03:00
Adjust archiveAll/readAll (#4972)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
ecf2a5193a
commit
76cf81381b
@ -258,10 +258,16 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
const ops = getClient().apply(generateId())
|
const ops = getClient().apply(generateId())
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
const inboxNotifications = await ops.findAll(
|
||||||
|
notification.class.InboxNotification,
|
||||||
|
{
|
||||||
|
user: getCurrentAccount()._id
|
||||||
|
},
|
||||||
|
{ projection: { _id: 1, _class: 1, space: 1 } }
|
||||||
|
)
|
||||||
const contexts = get(this.docNotifyContexts) ?? []
|
const contexts = get(this.docNotifyContexts) ?? []
|
||||||
for (const notification of inboxNotifications) {
|
for (const notification of inboxNotifications) {
|
||||||
await ops.remove(notification)
|
await ops.removeDoc(notification._class, notification.space, notification._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const context of contexts) {
|
for (const context of contexts) {
|
||||||
@ -278,12 +284,17 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
const ops = getClient().apply(generateId())
|
const ops = getClient().apply(generateId())
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
const inboxNotifications = await ops.findAll(
|
||||||
|
notification.class.InboxNotification,
|
||||||
|
{
|
||||||
|
user: getCurrentAccount()._id,
|
||||||
|
isViewed: { $ne: true }
|
||||||
|
},
|
||||||
|
{ projection: { _id: 1, _class: 1, space: 1 } }
|
||||||
|
)
|
||||||
const contexts = get(this.docNotifyContexts) ?? []
|
const contexts = get(this.docNotifyContexts) ?? []
|
||||||
for (const notification of inboxNotifications) {
|
for (const notification of inboxNotifications) {
|
||||||
if (!notification.isViewed) {
|
await ops.updateDoc(notification._class, notification.space, notification._id, { isViewed: true })
|
||||||
await ops.update(notification, { isViewed: true })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (const context of contexts) {
|
for (const context of contexts) {
|
||||||
await ops.update(context, { lastViewedTimestamp: Date.now() })
|
await ops.update(context, { lastViewedTimestamp: Date.now() })
|
||||||
@ -299,13 +310,18 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
const ops = getClient().apply(generateId())
|
const ops = getClient().apply(generateId())
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
const inboxNotifications = await ops.findAll(
|
||||||
|
notification.class.InboxNotification,
|
||||||
|
{
|
||||||
|
user: getCurrentAccount()._id,
|
||||||
|
isViewed: true
|
||||||
|
},
|
||||||
|
{ projection: { _id: 1, _class: 1, space: 1 } }
|
||||||
|
)
|
||||||
const contexts = get(this.docNotifyContexts) ?? []
|
const contexts = get(this.docNotifyContexts) ?? []
|
||||||
|
|
||||||
for (const notification of inboxNotifications) {
|
for (const notification of inboxNotifications) {
|
||||||
if (notification.isViewed) {
|
await ops.updateDoc(notification._class, notification.space, notification._id, { isViewed: false })
|
||||||
await ops.update(notification, { isViewed: false })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (const context of contexts) {
|
for (const context of contexts) {
|
||||||
await ops.update(context, { lastViewedTimestamp: 0 })
|
await ops.update(context, { lastViewedTimestamp: 0 })
|
||||||
|
Loading…
Reference in New Issue
Block a user