UBERF-5811: rework backlinks (#4887)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2024-03-07 13:53:07 +07:00
committed by GitHub
parent 049c3125b6
commit 734177f3ea
72 changed files with 1552 additions and 1412 deletions
@@ -19,8 +19,8 @@
NotificationProvider,
NotificationSetting,
NotificationStatus,
NotificationType,
Notification as PlatformNotification
Notification as PlatformNotification,
BaseNotificationType
} from '@hcengineering/notification'
import { createQuery, getClient } from '@hcengineering/presentation'
import { getCurrentLocation, showPanel } from '@hcengineering/ui'
@@ -32,7 +32,10 @@
const providersQuery = createQuery()
let settingsReceived = false
let settings: Map<Ref<NotificationType>, NotificationSetting> = new Map<Ref<NotificationType>, NotificationSetting>()
let settings: Map<Ref<BaseNotificationType>, NotificationSetting> = new Map<
Ref<BaseNotificationType>,
NotificationSetting
>()
let provider: NotificationProvider | undefined
$: enabled = 'Notification' in window && Notification?.permission !== 'denied'
@@ -15,6 +15,7 @@
<script lang="ts">
import { IdMap, Ref, toIdMap } from '@hcengineering/core'
import type {
BaseNotificationType,
NotificationGroup,
NotificationProvider,
NotificationSetting,
@@ -26,18 +27,18 @@
import notification from '../plugin'
export let group: Ref<NotificationGroup>
export let settings: Map<Ref<NotificationType>, NotificationSetting[]>
export let settings: Map<Ref<BaseNotificationType>, NotificationSetting[]>
const client = getClient()
let types: NotificationType[] = []
let typesMap: IdMap<NotificationType> = new Map()
let types: BaseNotificationType[] = []
let typesMap: IdMap<BaseNotificationType> = new Map()
let providers: NotificationProvider[] = []
let providersMap: IdMap<NotificationProvider> = new Map()
load()
void load()
const query = createQuery()
$: query.query(notification.class.NotificationType, { group }, (res) => {
$: query.query(notification.class.BaseNotificationType, { group }, (res) => {
types = res
typesMap = toIdMap(types)
})
@@ -50,8 +51,8 @@
$: column = providers.length + 1
function getStatus (
settings: Map<Ref<NotificationType>, NotificationSetting[]>,
type: Ref<NotificationType>,
settings: Map<Ref<BaseNotificationType>, NotificationSetting[]>,
type: Ref<BaseNotificationType>,
provider: Ref<NotificationProvider>
): boolean {
const setting = getSetting(settings, type, provider)
@@ -63,14 +64,14 @@
return typeValue?.providers?.[provider] ?? false
}
function createHandler (type: Ref<NotificationType>, provider: Ref<NotificationProvider>): (evt: any) => void {
function createHandler (type: Ref<BaseNotificationType>, provider: Ref<NotificationProvider>): (evt: any) => void {
return (evt: any) => {
void change(type, provider, evt.detail)
}
}
async function change (
type: Ref<NotificationType>,
type: Ref<BaseNotificationType>,
provider: Ref<NotificationProvider>,
value: boolean
): Promise<void> {
@@ -89,8 +90,8 @@
}
function getSetting (
map: Map<Ref<NotificationType>, NotificationSetting[]>,
type: Ref<NotificationType>,
map: Map<Ref<BaseNotificationType>, NotificationSetting[]>,
type: Ref<BaseNotificationType>,
provider: Ref<NotificationProvider>
): NotificationSetting | undefined {
const typeMap = map.get(type)
@@ -98,10 +99,15 @@
return typeMap.find((p) => p.attachedTo === provider)
}
function getLabel (type: NotificationType): IntlString {
if (type.attachedToClass !== undefined) {
const isNotificationType = (type: BaseNotificationType): type is NotificationType => {
return type._class === notification.class.NotificationType
}
function getLabel (type: BaseNotificationType): IntlString {
if (isNotificationType(type) && type.attachedToClass !== undefined) {
return notification.string.AddedRemoved
}
return notification.string.Change
}
</script>
@@ -16,10 +16,10 @@
import { createEventDispatcher, onDestroy } from 'svelte'
import { Ref } from '@hcengineering/core'
import type {
BaseNotificationType,
NotificationGroup,
NotificationPreferencesGroup,
NotificationSetting,
NotificationType
NotificationSetting
} from '@hcengineering/notification'
import { getResource } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
@@ -51,7 +51,7 @@
groups = res
})
let settings = new Map<Ref<NotificationType>, NotificationSetting[]>()
let settings = new Map<Ref<BaseNotificationType>, NotificationSetting[]>()
const query = createQuery()
@@ -23,7 +23,7 @@
EmployeePresenter
} from '@hcengineering/contact-resources'
import core, { Doc, getDisplayTime, Ref } from '@hcengineering/core'
import { translate } from '@hcengineering/platform'
import { IntlString, translate } from '@hcengineering/platform'
import { createQuery, getClient, MessageViewer } from '@hcengineering/presentation'
import notification, { CommonInboxNotification } from '@hcengineering/notification'
import { ActionIcon, IconMoreH, Label, showPopup } from '@hcengineering/ui'
@@ -61,13 +61,15 @@
object = result[0]
})
$: void translate(value.message, value.props)
.then((message) => {
content = message
})
.catch((err) => {
content = JSON.stringify(err, null, 2)
})
$: void updateContent(value.message, value.messageHtml)
async function updateContent (message?: IntlString, messageHtml?: string): Promise<void> {
if (messageHtml !== undefined) {
content = messageHtml
} else if (message !== undefined) {
content = await translate(message, value.props)
}
}
function handleActionMenuOpened (): void {
isActionMenuOpened = true
@@ -41,8 +41,7 @@
import { Ref, WithLookup } from '@hcengineering/core'
import { ViewletSelector } from '@hcengineering/view-resources'
import activity, { ActivityMessage } from '@hcengineering/activity'
import { isReactionMessage, loadSavedMessages } from '@hcengineering/activity-resources'
import { onMount } from 'svelte'
import { isReactionMessage } from '@hcengineering/activity-resources'
import { inboxMessagesStore, InboxNotificationsClientImpl } from '../../inboxNotificationsClient'
import Filter from '../Filter.svelte'
@@ -256,10 +255,6 @@
{ size: 'auto', minSize: 30, maxSize: 'auto', float: undefined }
])
onMount(() => {
loadSavedMessages()
})
function archiveAll (): void {
showPopup(
MessageBox,