Get rid of 'ne' in inbox queries (#6258)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-08-05 19:16:25 +04:00 committed by GitHub
parent c1508305bc
commit 32f0a7d9b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 39 additions and 15 deletions

View File

@ -228,7 +228,7 @@ export class TInboxNotification extends TDoc implements InboxNotification {
isViewed!: boolean isViewed!: boolean
@Prop(TypeBoolean(), core.string.Boolean) @Prop(TypeBoolean(), core.string.Boolean)
archived?: boolean archived!: boolean
title?: IntlString title?: IntlString
body?: IntlString body?: IntlString

View File

@ -25,7 +25,8 @@ import notification, {
notificationId, notificationId,
NotificationStatus, NotificationStatus,
type BrowserNotification, type BrowserNotification,
type DocNotifyContext type DocNotifyContext,
type InboxNotification
} from '@hcengineering/notification' } from '@hcengineering/notification'
import { DOMAIN_PREFERENCE } from '@hcengineering/preference' import { DOMAIN_PREFERENCE } from '@hcengineering/preference'
@ -166,6 +167,26 @@ export const notificationOperation: MigrateOperation = {
DOMAIN_USER_NOTIFY DOMAIN_USER_NOTIFY
) )
} }
},
{
state: 'fill-notification-archived-field-v1',
func: async (client) => {
await client.update<InboxNotification>(
DOMAIN_NOTIFICATION,
{ _class: notification.class.ActivityInboxNotification, archived: { $exists: false } },
{ archived: false }
)
await client.update<InboxNotification>(
DOMAIN_NOTIFICATION,
{ _class: notification.class.CommonInboxNotification, archived: { $exists: false } },
{ archived: false }
)
await client.update<InboxNotification>(
DOMAIN_NOTIFICATION,
{ _class: notification.class.MentionInboxNotification, archived: { $exists: false } },
{ archived: false }
)
}
} }
]) ])
await client.deleteMany<BrowserNotification>(DOMAIN_USER_NOTIFY, { await client.deleteMany<BrowserNotification>(DOMAIN_USER_NOTIFY, {

View File

@ -110,8 +110,8 @@
) )
archivedOtherNotificationsQuery.query( archivedOtherNotificationsQuery.query(
notification.class.InboxNotification, notification.class.CommonInboxNotification,
{ _class: { $ne: notification.class.ActivityInboxNotification }, archived: true, user: me._id }, { archived: true, user: me._id },
(res) => { (res) => {
archivedOtherNotifications = res archivedOtherNotifications = res
}, },

View File

@ -34,6 +34,7 @@ import notification, {
} from '@hcengineering/notification' } from '@hcengineering/notification'
import { createQuery, getClient } from '@hcengineering/presentation' import { createQuery, getClient } from '@hcengineering/presentation'
import { derived, get, writable } from 'svelte/store' import { derived, get, writable } from 'svelte/store'
import { isActivityNotification } from './utils' import { isActivityNotification } from './utils'
/** /**
@ -101,10 +102,9 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
} }
) )
this.otherInboxNotificationsQuery.query( this.otherInboxNotificationsQuery.query(
notification.class.InboxNotification, notification.class.CommonInboxNotification,
{ {
_class: { $ne: notification.class.ActivityInboxNotification }, archived: false,
archived: { $ne: true },
user: getCurrentAccount()._id user: getCurrentAccount()._id
}, },
(result: InboxNotification[]) => { (result: InboxNotification[]) => {
@ -120,7 +120,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
this.activityInboxNotificationsQuery.query( this.activityInboxNotificationsQuery.query(
notification.class.ActivityInboxNotification, notification.class.ActivityInboxNotification,
{ {
archived: { $ne: true }, archived: false,
user: getCurrentAccount()._id user: getCurrentAccount()._id
}, },
(result: ActivityInboxNotification[]) => { (result: ActivityInboxNotification[]) => {
@ -242,7 +242,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
notification.class.InboxNotification, notification.class.InboxNotification,
{ {
user: getCurrentAccount()._id, user: getCurrentAccount()._id,
archived: { $ne: true } archived: false
}, },
{ projection: { _id: 1, _class: 1, space: 1 } } { projection: { _id: 1, _class: 1, space: 1 } }
) )
@ -267,8 +267,8 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
notification.class.InboxNotification, notification.class.InboxNotification,
{ {
user: getCurrentAccount()._id, user: getCurrentAccount()._id,
isViewed: { $ne: true }, isViewed: false,
archived: { $ne: true } archived: false
}, },
{ projection: { _id: 1, _class: 1, space: 1 } } { projection: { _id: 1, _class: 1, space: 1 } }
) )
@ -293,7 +293,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
{ {
user: getCurrentAccount()._id, user: getCurrentAccount()._id,
isViewed: true, isViewed: true,
archived: { $ne: true } archived: false
}, },
{ {
projection: { _id: 1, _class: 1, space: 1, docNotifyContext: 1 }, projection: { _id: 1, _class: 1, space: 1, docNotifyContext: 1 },

View File

@ -186,7 +186,7 @@ export async function archiveContextNotifications (doc?: DocNotifyContext): Prom
try { try {
const notifications = await ops.findAll( const notifications = await ops.findAll(
notification.class.InboxNotification, notification.class.InboxNotification,
{ docNotifyContext: doc._id, archived: { $ne: true } }, { docNotifyContext: doc._id, archived: false },
{ projection: { _id: 1, _class: 1, space: 1 } } { projection: { _id: 1, _class: 1, space: 1 } }
) )

View File

@ -234,7 +234,7 @@ export interface InboxNotification extends Doc {
body?: IntlString body?: IntlString
intlParams?: Record<string, string | number> intlParams?: Record<string, string | number>
intlParamsNotLocalized?: Record<string, IntlString> intlParamsNotLocalized?: Record<string, IntlString>
archived?: boolean archived: boolean
} }
export interface ActivityInboxNotification extends InboxNotification { export interface ActivityInboxNotification extends InboxNotification {

View File

@ -157,7 +157,8 @@ export async function getPersonNotificationTxes (
mentionedIn: reference.attachedDocId ?? reference.srcDocId, mentionedIn: reference.attachedDocId ?? reference.srcDocId,
mentionedInClass: reference.attachedDocClass ?? reference.srcDocClass, mentionedInClass: reference.attachedDocClass ?? reference.srcDocClass,
user: receiver._id, user: receiver._id,
isViewed: false isViewed: false,
archived: false
} }
const sender = ( const sender = (

View File

@ -381,6 +381,7 @@ export async function pushInboxNotifications (
user: account._id, user: account._id,
isViewed: false, isViewed: false,
docNotifyContext: docNotifyContextId, docNotifyContext: docNotifyContextId,
archived: false,
...data ...data
} }
const notificationTx = control.txFactory.createTxCreateDoc(_class, space, notificationData) const notificationTx = control.txFactory.createTxCreateDoc(_class, space, notificationData)

View File

@ -38,6 +38,7 @@ export async function createNotification (
message: data.message, message: data.message,
props: data.props, props: data.props,
isViewed: false, isViewed: false,
archived: false,
docNotifyContext: docNotifyContext?._id as Ref<DocNotifyContext> docNotifyContext: docNotifyContext?._id as Ref<DocNotifyContext>
}) })
} }