@@ -34,20 +34,22 @@ import {
3434} from '@hcengineering/ui'
3535import { handleDownloadItem } from '@hcengineering/desktop-downloads'
3636import notification , { notificationId } from '@hcengineering/notification'
37- import { chatId } from '@hcengineering/chat '
37+ import { inboxId } from '@hcengineering/inbox '
3838import workbench , { workbenchId , logOut } from '@hcengineering/workbench'
3939import view , { Action , encodeObjectURI } from '@hcengineering/view'
4040import { resolveLocation } from '@hcengineering/notification-resources'
41+ import { themeStore , ThemeVariant } from '@hcengineering/theme'
42+ import type { Application } from '@hcengineering/workbench'
43+ import { isAllowedToRole } from '@hcengineering/workbench-resources'
44+ import card from '@hcengineering/card'
45+ import communication from '@hcengineering/communication'
4146
4247import { isOwnerOrMaintainer , getCurrentAccount , Ref } from '@hcengineering/core'
4348import { configurePlatform } from './platform'
4449import { setupTitleBarMenu } from './titleBarMenu'
4550import { defineScreenShare , defineGetDisplayMedia } from './screenShare'
4651import { CommandLogout , CommandSelectWorkspace , CommandOpenSettings , CommandOpenInbox , CommandOpenPlanner , CommandOpenOffice , CommandOpenApplication , LaunchApplication , NotificationParams , CommandCloseTab } from './types'
4752import { ipcMainExposed } from './typesUtils'
48- import { themeStore , ThemeVariant } from '@hcengineering/theme'
49- import type { Application } from '@hcengineering/workbench'
50- import { isAllowedToRole } from '@hcengineering/workbench-resources'
5153import { IpcMessage } from './ipcMessages'
5254
5355function currentOsIsWindows ( ) : boolean {
@@ -197,39 +199,44 @@ window.addEventListener('DOMContentLoaded', () => {
197199 navigate ( parseLocation ( urlObject ) )
198200 }
199201
200- function getBasicNotificationPath ( notificationParams : NotificationParams ) : string {
201- return `${ workbenchId } /${ notificationParams . application ?? notificationId } /${ notificationId } `
202+ function getBasicNotificationPath ( worksapce : string , app : string ) : string {
203+ return `${ workbenchId } /${ worksapce } /${ app } `
202204 }
203205
204206 ipcMain . handleNotificationNavigation ( ( notificationParams : NotificationParams ) => {
207+ const currentLocation = getCurrentResolvedLocation ( )
208+ const workspace = currentLocation . path [ 1 ]
205209 // Support for new inbox with cardId (card-based)
206210 if ( notificationParams . cardId != null ) {
207- const currentLocation = getCurrentResolvedLocation ( )
208- navigateToUrl ( `${ workbenchId } /${ currentLocation . path [ 1 ] } /${ chatId } /${ notificationParams . cardId } ` )
211+ const objectUri = encodeObjectURI ( notificationParams . cardId , card . class . Card )
212+ navigateToUrl ( `${ workbenchId } /${ workspace } /${ inboxId } /${ objectUri } ` )
209213 return
210214 }
211215
216+ const isCommunicationEnabled = getMetadata ( communication . metadata . Enabled ) ?? false
217+ const app = isCommunicationEnabled ? inboxId : notificationParams . application
218+
212219 // Support for old inbox with objectId + objectClass (legacy)
213220 if ( notificationParams . objectId != null && notificationParams . objectClass != null ) {
214221 const encodedObjectURI = encodeObjectURI ( notificationParams . objectId , notificationParams . objectClass )
215222 const notificationLocation = {
216- path : [ workbenchId , notificationParams . application , notificationId , encodedObjectURI ] ,
223+ path : [ workbenchId , workspace , app , encodedObjectURI ] ,
217224 fragment : undefined ,
218- query : { }
225+ query : undefined
219226 }
220227
221228 void resolveLocation ( notificationLocation ) . then ( ( resolvedLocation ) => {
222229 if ( resolvedLocation ?. loc != null ) {
223230 navigate ( resolvedLocation . loc )
224231 } else {
225- navigateToUrl ( `${ workbenchId } /${ notificationParams . application } /${ notificationId } /${ encodedObjectURI } ` )
232+ navigateToUrl ( `${ workbenchId } /${ workspace } /${ app } /${ encodedObjectURI } ` )
226233 }
227234 } ) . catch ( ( ) => {
228- navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
235+ navigateToUrl ( getBasicNotificationPath ( workspace , app ) )
229236 } )
230237 } else {
231238 // Fallback to basic notification navigation
232- navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
239+ navigateToUrl ( getBasicNotificationPath ( workspace , app ) )
233240 }
234241 } )
235242
0 commit comments