diff --git a/models/inbox/src/index.ts b/models/inbox/src/index.ts index bde12f03ac6..abe9bbbfc9d 100644 --- a/models/inbox/src/index.ts +++ b/models/inbox/src/index.ts @@ -32,7 +32,7 @@ export function createModel (builder: Builder): void { label: inbox.string.Inbox, icon: inbox.icon.Inbox, alias: inboxId, - hidden: false, + hidden: true, component: inbox.component.InboxApplication, position: 'top', order: 100 diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index 380156d6b90..8b19761eb36 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -29,11 +29,13 @@ import login, { loginId } from '@hcengineering/login' import notification, { DocNotifyContext, InboxNotification, notificationId } from '@hcengineering/notification' import { BrowserNotificatator, InboxNotificationsClientImpl } from '@hcengineering/notification-resources' + import inbox, { inboxId } from '@hcengineering/inbox' import { broadcastEvent, getMetadata, getResource, IntlString, translate } from '@hcengineering/platform' import { ActionContext, ComponentExtensions, createQuery, + createNotificationsQuery, getClient, isAdminUser, reduceCalls @@ -282,6 +284,17 @@ hasInboxNotifications = res }) + let hasNewInboxNotifications = false + + $: if (isCommunicationEnabled) { + const notificationCountQuery = createNotificationsQuery() + notificationCountQuery.query({ read: false, limit: 1 }, (res) => { + hasNewInboxNotifications = res.getResult().length > 0 + }) + } else { + hasNewInboxNotifications = false + } + const doSyncLoc = reduceCalls(async (loc: Location): Promise => { if (workspaceId !== $location.path[1]) { tabs = [] @@ -759,15 +772,17 @@ let inboxPopup: PopupResult | undefined = undefined let lastLoc: Location | undefined = undefined + $: activeInboxId = isCommunicationEnabled ? inboxId : notificationId + $: inboxProps = { - selected: currentAppAlias === notificationId || inboxPopup !== undefined, - navigator: (currentAppAlias === notificationId || inboxPopup !== undefined) && $deviceInfo.navigator.visible, - notify: hasInboxNotifications, + selected: currentAppAlias === activeInboxId || inboxPopup !== undefined, + navigator: (currentAppAlias === activeInboxId || inboxPopup !== undefined) && $deviceInfo.navigator.visible, + notify: isCommunicationEnabled ? hasInboxNotifications || hasNewInboxNotifications : hasInboxNotifications, onClick: (e: MouseEvent) => { if (e.metaKey || e.ctrlKey) return - if (!$deviceInfo.navigator.visible && $deviceInfo.navigator.float && currentAppAlias === notificationId) { + if (!$deviceInfo.navigator.visible && $deviceInfo.navigator.float && currentAppAlias === activeInboxId) { toggleNav() - } else if (currentAppAlias === notificationId && lastLoc !== undefined) { + } else if (currentAppAlias === activeInboxId && lastLoc !== undefined) { e.preventDefault() e.stopPropagation() navigate(lastLoc) @@ -778,7 +793,10 @@ } } - $: customAppProps = new Map([[notificationId, inboxProps]]) + $: customAppProps = new Map([ + [notificationId, inboxProps], + [inboxId, inboxProps] + ]) defineSeparators('workbench', workbenchSeparators) defineSeparators('main', mainSeparators) @@ -859,22 +877,36 @@ on:click={toggleNav} /> - - {#if !isExcludedApp(notificationId) && !isCommunicationEnabled} - - - + {#if !isExcludedApp(activeInboxId)} + {#if !isCommunicationEnabled} + + + + {:else} + + + + {/if} {/if}