diff --git a/models/notification/src/migration.ts b/models/notification/src/migration.ts index 4c67119729..19405eaf68 100644 --- a/models/notification/src/migration.ts +++ b/models/notification/src/migration.ts @@ -399,6 +399,18 @@ export const notificationOperation: MigrateOperation = { func: async (client: MigrationClient): Promise => { await client.update(DOMAIN_DOC_NOTIFY, { '%hash%': { $exists: true } }, { $set: { '%hash%': null } }) } + }, + { + state: 'remove-update-txes-docnotify-ctx', + func: async (client) => { + await client.deleteMany(DOMAIN_TX, { + _class: core.class.TxUpdateDoc, + objectClass: notification.class.DocNotifyContext, + 'operations.lastViewedTimestamp': { + $exists: true + } + }) + } } ]) diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts index 8d55f8ec82..c8d40c1c62 100644 --- a/packages/core/src/operations.ts +++ b/packages/core/src/operations.ts @@ -313,8 +313,8 @@ export class TxOperations implements Omit { return this.removeDoc(doc._class, doc.space, doc._id) } - apply (scope?: string, measure?: string): ApplyOperations { - return new ApplyOperations(this, scope, measure, this.isDerived) + apply (scope?: string, measure?: string, derived?: boolean): ApplyOperations { + return new ApplyOperations(this, scope, measure, derived ?? this.isDerived) } async diffUpdate( diff --git a/packages/core/src/server.ts b/packages/core/src/server.ts index 8ae4596a6e..5a16bfa67d 100644 --- a/packages/core/src/server.ts +++ b/packages/core/src/server.ts @@ -85,6 +85,8 @@ export interface LowLevelStorage { rawUpdate: (domain: Domain, query: DocumentQuery, operations: DocumentUpdate) => Promise + rawDeleteMany: (domain: Domain, query: DocumentQuery) => Promise + // Traverse documents traverse: ( domain: Domain, diff --git a/plugins/chunter-resources/src/components/ChannelScrollView.svelte b/plugins/chunter-resources/src/components/ChannelScrollView.svelte index a17e633496..d606e645e4 100644 --- a/plugins/chunter-resources/src/components/ChannelScrollView.svelte +++ b/plugins/chunter-resources/src/components/ChannelScrollView.svelte @@ -760,7 +760,7 @@ if (unViewed.length === 0) { forceRead = true - const op = client.apply(undefined, 'chunter.forceReadContext') + const op = client.apply(undefined, 'chunter.forceReadContext', true) await inboxClient.readDoc(op, object._id) await op.commit() } diff --git a/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte b/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte index 9f8353db0b..027478ef15 100644 --- a/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte +++ b/plugins/chunter-resources/src/components/ReverseChannelScrollView.svelte @@ -419,7 +419,7 @@ if (unViewed.length === 0) { forceRead = true - const op = client.apply(undefined, 'chunter.forceReadContext') + const op = client.apply(undefined, 'chunter.forceReadContext', true) await inboxClient.readDoc(op, object._id) await op.commit() } diff --git a/plugins/chunter-resources/src/components/chat/utils.ts b/plugins/chunter-resources/src/components/chat/utils.ts index 377cd196d8..203b576a06 100644 --- a/plugins/chunter-resources/src/components/chat/utils.ts +++ b/plugins/chunter-resources/src/components/chat/utils.ts @@ -400,7 +400,7 @@ export async function hideActivityChannels (contexts: DocNotifyContext[]): Promi export async function readActivityChannels (contexts: DocNotifyContext[]): Promise { const client = InboxNotificationsClientImpl.getClient() const notificationsByContext = get(client.inboxNotificationsByContext) - const ops = getClient().apply(undefined, 'readActivityChannels') + const ops = getClient().apply(undefined, 'readActivityChannels', true) try { for (const context of contexts) { diff --git a/plugins/notification-resources/src/inboxNotificationsClient.ts b/plugins/notification-resources/src/inboxNotificationsClient.ts index 19369b51d6..8d9585bfc7 100644 --- a/plugins/notification-resources/src/inboxNotificationsClient.ts +++ b/plugins/notification-resources/src/inboxNotificationsClient.ts @@ -235,7 +235,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient { } async archiveAllNotifications (): Promise { - const ops = getClient().apply(undefined, 'archiveAllNotifications') + const ops = getClient().apply(undefined, 'archiveAllNotifications', true) try { const inboxNotifications = await ops.findAll( @@ -260,7 +260,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient { } async readAllNotifications (): Promise { - const ops = getClient().apply(undefined, 'readAllNotifications') + const ops = getClient().apply(undefined, 'readAllNotifications', true) try { const inboxNotifications = await ops.findAll( @@ -285,7 +285,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient { } async unreadAllNotifications (): Promise { - const ops = getClient().apply(undefined, 'unreadAllNotifications') + const ops = getClient().apply(undefined, 'unreadAllNotifications', true) try { const inboxNotifications = await ops.findAll( diff --git a/plugins/notification-resources/src/utils.ts b/plugins/notification-resources/src/utils.ts index f5977d1d8d..cf07387a79 100644 --- a/plugins/notification-resources/src/utils.ts +++ b/plugins/notification-resources/src/utils.ts @@ -128,7 +128,7 @@ export async function readNotifyContext (doc: DocNotifyContext): Promise { const inboxClient = InboxNotificationsClientImpl.getClient() const inboxNotifications = get(inboxClient.inboxNotificationsByContext).get(doc._id) ?? [] - const ops = getClient().apply(undefined, 'readNotifyContext') + const ops = getClient().apply(undefined, 'readNotifyContext', true) try { await inboxClient.readNotifications( ops, @@ -152,7 +152,7 @@ export async function unReadNotifyContext (doc: DocNotifyContext): Promise return } - const ops = getClient().apply(undefined, 'unReadNotifyContext') + const ops = getClient().apply(undefined, 'unReadNotifyContext', true) try { await inboxClient.unreadNotifications( diff --git a/plugins/workbench-resources/src/components/WorkbenchTabPresenter.svelte b/plugins/workbench-resources/src/components/WorkbenchTabPresenter.svelte index 12dcd0f5f0..48d6df9bdf 100644 --- a/plugins/workbench-resources/src/components/WorkbenchTabPresenter.svelte +++ b/plugins/workbench-resources/src/components/WorkbenchTabPresenter.svelte @@ -13,24 +13,24 @@ // limitations under the License. -->