mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-25 20:42:56 +03:00
Fix hidden notifications (#4436)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
8865bdd516
commit
b15f94f885
@ -44,7 +44,6 @@
|
||||
import Filter from '../Filter.svelte'
|
||||
import { getDisplayInboxNotifications, resolveLocation } from '../../utils'
|
||||
import { InboxNotificationsFilter } from '../../types'
|
||||
import { onDestroy } from 'svelte'
|
||||
|
||||
export let visibleNav: boolean = true
|
||||
export let navFloat: boolean = false
|
||||
@ -91,7 +90,9 @@
|
||||
viewlets = res
|
||||
})
|
||||
|
||||
$: displayNotifications = getDisplayInboxNotifications($notificationsByContextStore, filter)
|
||||
$: getDisplayInboxNotifications($notificationsByContextStore, filter).then((res) => {
|
||||
displayNotifications = res
|
||||
})
|
||||
$: displayContextsIds = new Set(displayNotifications.map(({ docNotifyContext }) => docNotifyContext))
|
||||
|
||||
$: filteredNotifications = filterNotifications(selectedTabId, displayNotifications, $notifyContextsStore)
|
||||
|
@ -76,14 +76,14 @@
|
||||
key.preventDefault()
|
||||
key.stopPropagation()
|
||||
|
||||
const context = $notifyContextsStore.find(({ _id }) => _id === displayData[listSelection][0])
|
||||
const context = $notifyContextsStore.find(({ _id }) => _id === displayData[listSelection]?.[0])
|
||||
|
||||
deleteContextNotifications(context)
|
||||
}
|
||||
if (key.code === 'Enter') {
|
||||
key.preventDefault()
|
||||
key.stopPropagation()
|
||||
const context = $notifyContextsStore.find(({ _id }) => _id === displayData[listSelection][0])
|
||||
const context = $notifyContextsStore.find(({ _id }) => _id === displayData[listSelection]?.[0])
|
||||
dispatch('click', { context })
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import { activityMessagesComparator, combineActivityMessages } from '@hcengineer
|
||||
|
||||
import { type InboxNotificationsFilter } from './types'
|
||||
import { InboxNotificationsClientImpl } from './inboxNotificationsClient'
|
||||
import { checkIsObjectRemoved } from '@hcengineering/view-resources'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -355,11 +356,12 @@ async function generateLocation (
|
||||
}
|
||||
}
|
||||
|
||||
export function getDisplayInboxNotifications (
|
||||
export async function getDisplayInboxNotifications (
|
||||
notificationsByContext: Map<Ref<DocNotifyContext>, InboxNotification[]>,
|
||||
filter: InboxNotificationsFilter = 'all',
|
||||
objectClass?: Ref<Class<Doc>>
|
||||
): DisplayInboxNotification[] {
|
||||
): Promise<DisplayInboxNotification[]> {
|
||||
const client = getClient()
|
||||
const filteredNotifications = Array.from(notificationsByContext.values())
|
||||
.flat()
|
||||
.filter(({ isViewed }) => {
|
||||
@ -375,6 +377,10 @@ export function getDisplayInboxNotifications (
|
||||
}
|
||||
})
|
||||
|
||||
const viewletsHideIfRemoved = client
|
||||
.getModel()
|
||||
.findAllSync(activity.class.DocUpdateMessageViewlet, { hideIfRemoved: true })
|
||||
|
||||
const activityNotifications = filteredNotifications.filter(
|
||||
(n): n is WithLookup<ActivityInboxNotification> => n._class === notification.class.ActivityInboxNotification
|
||||
)
|
||||
@ -397,9 +403,31 @@ export function getDisplayInboxNotifications (
|
||||
|
||||
return (message as DocUpdateMessage).objectClass === objectClass
|
||||
})
|
||||
.sort(activityMessagesComparator)
|
||||
|
||||
const combinedMessages = combineActivityMessages(messages, SortingOrder.Descending)
|
||||
for (const [index, message] of messages.entries()) {
|
||||
if (message._class !== activity.class.DocUpdateMessage) {
|
||||
continue
|
||||
}
|
||||
|
||||
const docUpdateMessage = message as DocUpdateMessage
|
||||
|
||||
const hideIfRemoved = viewletsHideIfRemoved.some(
|
||||
(viewlet) => viewlet.action === docUpdateMessage.action && viewlet.objectClass === docUpdateMessage.objectClass
|
||||
)
|
||||
|
||||
if (!hideIfRemoved) {
|
||||
continue
|
||||
}
|
||||
|
||||
const isRemoved = await checkIsObjectRemoved(client, docUpdateMessage.objectId, docUpdateMessage.objectClass)
|
||||
|
||||
if (isRemoved) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete messages[index]
|
||||
}
|
||||
}
|
||||
|
||||
const combinedMessages = combineActivityMessages(messages.sort(activityMessagesComparator), SortingOrder.Descending)
|
||||
|
||||
for (const message of combinedMessages) {
|
||||
if (message._class === activity.class.DocUpdateMessage) {
|
||||
@ -439,7 +467,7 @@ export function getDisplayInboxNotifications (
|
||||
export async function hasInboxNotifications (
|
||||
notificationsByContext: Map<Ref<DocNotifyContext>, InboxNotification[]>
|
||||
): Promise<boolean> {
|
||||
const displayNotifications = getDisplayInboxNotifications(notificationsByContext)
|
||||
const displayNotifications = await getDisplayInboxNotifications(notificationsByContext)
|
||||
|
||||
return displayNotifications.some(({ isViewed }) => !isViewed)
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ import core, {
|
||||
type TxCreateDoc,
|
||||
type TxUpdateDoc,
|
||||
type TxMixin,
|
||||
ClassifierKind
|
||||
ClassifierKind,
|
||||
type TypeAny
|
||||
} from '@hcengineering/core'
|
||||
import type { Asset, IntlString } from '@hcengineering/platform'
|
||||
import { getResource, translate } from '@hcengineering/platform'
|
||||
@ -172,6 +173,7 @@ export async function getAttributePresenter (
|
||||
|
||||
const hierarchy = client.getHierarchy()
|
||||
const attribute = hierarchy.getAttribute(_class, key)
|
||||
|
||||
const presenterClass = getAttributePresenterClass(hierarchy, attribute)
|
||||
const isCollectionAttr = presenterClass.category === 'collection'
|
||||
const mixin = isCollectionAttr ? view.mixin.CollectionPresenter : actualMixinClass
|
||||
@ -181,7 +183,15 @@ export async function getAttributePresenter (
|
||||
if (presenterMixin?.presenter === undefined && mixinClass != null && mixin === mixinClass) {
|
||||
presenterMixin = hierarchy.classHierarchyMixin(presenterClass.attrClass, view.mixin.AttributePresenter)
|
||||
}
|
||||
if (presenterMixin?.presenter === undefined) {
|
||||
|
||||
let presenter: AnySvelteComponent
|
||||
|
||||
if (presenterMixin?.presenter !== undefined) {
|
||||
presenter = await getResource(presenterMixin.presenter)
|
||||
} else if (presenterClass.attrClass === core.class.TypeAny) {
|
||||
const typeAny = attribute.type as TypeAny
|
||||
presenter = await getResource(typeAny.presenter)
|
||||
} else {
|
||||
throw new Error('attribute presenter not found for ' + JSON.stringify(preserveKey))
|
||||
}
|
||||
|
||||
@ -191,7 +201,6 @@ export async function getAttributePresenter (
|
||||
: attribute.type._class === core.class.ArrOf
|
||||
? resultKey + '.length'
|
||||
: resultKey
|
||||
const presenter = await getResource(presenterMixin.presenter)
|
||||
|
||||
return {
|
||||
key: preserveKey.key,
|
||||
@ -201,7 +210,7 @@ export async function getAttributePresenter (
|
||||
presenter,
|
||||
props: preserveKey.props,
|
||||
displayProps: preserveKey.displayProps,
|
||||
icon: presenterMixin.icon,
|
||||
icon: presenterMixin?.icon,
|
||||
attribute,
|
||||
collectionAttr: isCollectionAttr,
|
||||
isLookup: false
|
||||
|
Loading…
Reference in New Issue
Block a user