@@ -32,6 +32,8 @@ import { ipcMainExposed } from './typesUtils'
3232import { themeStore , ThemeVariant } from '@hcengineering/theme'
3333import type { Application } from '@hcengineering/workbench'
3434import { isAllowedToRole } from '@hcengineering/workbench-resources'
35+ import card from '@hcengineering/card'
36+ import communication from '@hcengineering/communication'
3537
3638function currentOsIsWindows ( ) : boolean {
3739 return ( window as any ) . windowsPlatform === true
@@ -178,39 +180,44 @@ window.addEventListener('DOMContentLoaded', () => {
178180 navigate ( parseLocation ( urlObject ) )
179181 }
180182
181- function getBasicNotificationPath ( notificationParams : NotificationParams ) : string {
182- return `${ workbenchId } /${ notificationParams . application ?? notificationId } /${ notificationId } `
183+ function getBasicNotificationPath ( worksapce : string , app : string ) : string {
184+ return `${ workbenchId } /${ worksapce } /${ app } `
183185 }
184186
185187 ipcMain . handleNotificationNavigation ( ( notificationParams : NotificationParams ) => {
188+ const currentLocation = getCurrentResolvedLocation ( )
189+ const workspace = currentLocation . path [ 1 ]
186190 // Support for new inbox with cardId (card-based)
187191 if ( notificationParams . cardId != null ) {
188- const currentLocation = getCurrentResolvedLocation ( )
189- navigateToUrl ( `${ workbenchId } /${ currentLocation . path [ 1 ] } /${ inboxId } /${ notificationParams . cardId } ` )
192+ const objectUri = encodeObjectURI ( notificationParams . cardId , card . class . Card )
193+ navigateToUrl ( `${ workbenchId } /${ workspace } /${ inboxId } /${ objectUri } ` )
190194 return
191195 }
192196
197+ const isCommunicationEnabled = getMetadata ( communication . metadata . Enabled ) ?? false
198+ const app = isCommunicationEnabled ? inboxId : notificationParams . application
199+
193200 // Support for old inbox with objectId + objectClass (legacy)
194201 if ( notificationParams . objectId != null && notificationParams . objectClass != null ) {
195202 const encodedObjectURI = encodeObjectURI ( notificationParams . objectId , notificationParams . objectClass )
196203 const notificationLocation = {
197- path : [ workbenchId , notificationParams . application , notificationId , encodedObjectURI ] ,
204+ path : [ workbenchId , workspace , app , encodedObjectURI ] ,
198205 fragment : undefined ,
199- query : { }
206+ query : undefined
200207 }
201208
202209 void resolveLocation ( notificationLocation ) . then ( ( resolvedLocation ) => {
203210 if ( resolvedLocation ?. loc != null ) {
204211 navigate ( resolvedLocation . loc )
205212 } else {
206- navigateToUrl ( `${ workbenchId } /${ notificationParams . application } /${ notificationId } /${ encodedObjectURI } ` )
213+ navigateToUrl ( `${ workbenchId } /${ workspace } /${ app } /${ encodedObjectURI } ` )
207214 }
208215 } ) . catch ( ( ) => {
209- navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
216+ navigateToUrl ( getBasicNotificationPath ( workspace , app ) )
210217 } )
211218 } else {
212219 // Fallback to basic notification navigation
213- navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
220+ navigateToUrl ( getBasicNotificationPath ( workspace , app ) )
214221 }
215222 } )
216223
0 commit comments