Implement @everyone/@here (#8890)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2025-05-12 14:42:58 +07:00
committed by GitHub
parent 137260fe5b
commit 3295adee57
47 changed files with 675 additions and 351 deletions
@@ -61,11 +61,12 @@
function updateDisplayData (data: InboxData): void {
let result: [Ref<DocNotifyContext>, DisplayInboxNotification[]][] = Array.from(data.entries())
if (archivedContexts.size > 0) {
result = result.filter(([contextId]) => {
result = result.filter(([contextId, d]) => {
const context = $contextByIdStore.get(contextId)
return (
!archivedContexts.has(contextId) ||
(context?.lastUpdateTimestamp ?? 0) > (archivedContexts.get(contextId) ?? 0)
(context?.lastUpdateTimestamp ?? 0) > (archivedContexts.get(contextId) ?? 0) ||
(d[0]?.createdOn ?? 0) > (archivedContexts.get(contextId) ?? 0)
)
})
}
@@ -0,0 +1,47 @@
<!--
// Copyright © 2023 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { ActivityMessagePreview } from '@hcengineering/activity-resources'
import { MentionInboxNotification } from '@hcengineering/notification'
import { createQuery, getClient } from '@hcengineering/presentation'
import activity, { ActivityMessage } from '@hcengineering/activity'
import { Doc, Ref, Space } from '@hcengineering/core'
import CommonInboxNotificationPresenter from './CommonInboxNotificationPresenter.svelte'
export let object: Doc | undefined
export let value: MentionInboxNotification
export let space: Ref<Space> | undefined = undefined
const client = getClient()
const hierarchy = client.getHierarchy()
const query = createQuery()
let message: ActivityMessage | undefined = undefined
$: if (hierarchy.isDerived(value.mentionedInClass, activity.class.ActivityMessage)) {
query.query(value.mentionedInClass, { _id: value.mentionedIn }, (res) => {
message = res[0] as ActivityMessage
})
} else {
query.unsubscribe()
}
</script>
{#if message}
<ActivityMessagePreview value={message} {space} doc={object} on:click />
{:else}
<CommonInboxNotificationPresenter {value} on:click />
{/if}
@@ -15,10 +15,9 @@
<script lang="ts">
import core, { IdMap, Ref, toIdMap } from '@hcengineering/core'
import {
BaseNotificationType,
NotificationType,
NotificationProvider,
NotificationGroup,
NotificationType,
NotificationTypeSetting,
NotificationProviderDefaults,
NotificationProviderSetting
@@ -31,7 +30,7 @@
import { providersSettings } from '../../utils'
export let group: Ref<NotificationGroup>
export let settings: Map<Ref<BaseNotificationType>, NotificationTypeSetting[]>
export let settings: Map<Ref<NotificationType>, NotificationTypeSetting[]>
const client = getClient()
@@ -44,12 +43,12 @@
.findAllSync(notification.class.NotificationProviderDefaults, {})
const providersMap: IdMap<NotificationProvider> = toIdMap(providers)
$: types = client.getModel().findAllSync(notification.class.BaseNotificationType, { group })
$: types = client.getModel().findAllSync(notification.class.NotificationType, { group })
$: typesMap = toIdMap(types)
function getStatus (
settings: Map<Ref<BaseNotificationType>, NotificationTypeSetting[]>,
type: Ref<BaseNotificationType>,
settings: Map<Ref<NotificationType>, NotificationTypeSetting[]>,
type: Ref<NotificationType>,
provider: Ref<NotificationProvider>
): boolean {
const setting = getTypeSetting(settings, type, provider)
@@ -64,7 +63,7 @@
}
async function onToggle (
typeId: Ref<BaseNotificationType>,
typeId: Ref<NotificationType>,
providerId: Ref<NotificationProvider>,
value: boolean
): Promise<void> {
@@ -96,8 +95,8 @@
}
function getTypeSetting (
map: Map<Ref<BaseNotificationType>, NotificationTypeSetting[]>,
type: Ref<BaseNotificationType>,
map: Map<Ref<NotificationType>, NotificationTypeSetting[]>,
type: Ref<NotificationType>,
provider: Ref<NotificationProvider>
): NotificationTypeSetting | undefined {
const typeMap = map.get(type)
@@ -105,11 +104,11 @@
return typeMap.find((p) => p.attachedTo === provider)
}
const isNotificationType = (type: BaseNotificationType): type is NotificationType => {
const isNotificationType = (type: NotificationType): type is NotificationType => {
return type._class === notification.class.NotificationType
}
function getLabel (type: BaseNotificationType): IntlString {
function getLabel (type: NotificationType): IntlString {
if (isNotificationType(type) && type.attachedToClass !== undefined) {
return notification.string.AddedRemoved
}
@@ -117,7 +116,7 @@
return notification.string.Change
}
function isIgnored (type: Ref<BaseNotificationType>, provider: NotificationProvider): boolean {
function isIgnored (type: Ref<NotificationType>, provider: NotificationProvider): boolean {
const ignored = providerDefaults.some((it) => provider._id === it.provider && it.ignoredTypes.includes(type))
if (ignored) return true
@@ -133,7 +132,7 @@
async function getFilteredProviders (
providers: NotificationProvider[],
types: BaseNotificationType[],
types: NotificationType[],
providersSettings: NotificationProviderSetting[]
): Promise<NotificationProvider[]> {
const result: NotificationProvider[] = []
@@ -16,7 +16,7 @@
import { onDestroy } from 'svelte'
import { Ref } from '@hcengineering/core'
import type {
BaseNotificationType,
NotificationType,
NotificationGroup,
NotificationPreferencesGroup,
NotificationTypeSetting
@@ -48,7 +48,7 @@
.getModel()
.findAllSync(notification.class.NotificationPreferencesGroup, {})
let settings = new Map<Ref<BaseNotificationType>, NotificationTypeSetting[]>()
let settings = new Map<Ref<NotificationType>, NotificationTypeSetting[]>()
let isProviderSettingLoading = true
let isTypeSettingLoading = true