@@ -18,6 +18,7 @@ import {
18
18
} from '@hcengineering/ui'
19
19
import { handleDownloadItem } from '@hcengineering/desktop-downloads'
20
20
import { notificationId } from '@hcengineering/notification'
21
+ import { inboxId } from '@hcengineering/inbox'
21
22
import { workbenchId , logOut } from '@hcengineering/workbench'
22
23
import { encodeObjectURI } from '@hcengineering/view'
23
24
import { resolveLocation } from '@hcengineering/notification-resources'
@@ -26,7 +27,7 @@ import { isOwnerOrMaintainer } from '@hcengineering/core'
26
27
import { configurePlatform } from './platform'
27
28
import { setupTitleBarMenu } from './titleBarMenu'
28
29
import { defineScreenShare , defineGetDisplayMedia } from './screenShare'
29
- import { CommandLogout , CommandSelectWorkspace , CommandOpenSettings , CommandOpenInbox , CommandOpenPlanner , CommandOpenOffice } from './types'
30
+ import { CommandLogout , CommandSelectWorkspace , CommandOpenSettings , CommandOpenInbox , CommandOpenPlanner , CommandOpenOffice , NotificationParams } from './types'
30
31
import { ipcMainExposed } from './typesUtils'
31
32
import { themeStore } from '@hcengineering/theme'
32
33
@@ -116,43 +117,45 @@ window.addEventListener('DOMContentLoaded', () => {
116
117
navigate ( parseLocation ( urlObject ) )
117
118
} )
118
119
119
- ipcMain . handleNotificationNavigation ( ( notificationParams ) => {
120
- // If we have notification location data, use it for proper navigation
121
- if ( notificationParams . objectId != null && notificationParams . objectClass != null && notificationParams . docNotifyContext != null ) {
122
- const frontUrl = getMetadata ( presentation . metadata . FrontUrl ) ?? window . location . origin
120
+ function navigateToUrl ( path : string ) : void {
121
+ const frontUrl = getMetadata ( presentation . metadata . FrontUrl ) ?? window . location . origin
122
+ const urlObject = new URL ( `${ frontUrl } /${ path } ` )
123
+ navigate ( parseLocation ( urlObject ) )
124
+ }
125
+
126
+ function getBasicNotificationPath ( notificationParams : NotificationParams ) : string {
127
+ return `${ workbenchId } /${ notificationParams . application ?? notificationId } /${ notificationId } `
128
+ }
129
+
130
+ ipcMain . handleNotificationNavigation ( ( notificationParams : NotificationParams ) => {
131
+ // Support for new inbox with cardId (card-based)
132
+ if ( notificationParams . cardId != null ) {
123
133
const currentLocation = getCurrentResolvedLocation ( )
124
- const encodedObjectURI = encodeObjectURI ( notificationParams . objectId , notificationParams . objectClass as any )
134
+ navigateToUrl ( `${ workbenchId } /${ currentLocation . path [ 1 ] } /${ inboxId } /${ notificationParams . cardId } ` )
135
+ return
136
+ }
125
137
138
+ // Support for old inbox with objectId + objectClass (legacy)
139
+ if ( notificationParams . objectId != null && notificationParams . objectClass != null ) {
140
+ const encodedObjectURI = encodeObjectURI ( notificationParams . objectId , notificationParams . objectClass )
126
141
const notificationLocation = {
127
- path : [ workbenchId , currentLocation . path [ 1 ] , notificationId , encodedObjectURI ] ,
142
+ path : [ workbenchId , notificationParams . application , notificationId , encodedObjectURI ] ,
128
143
fragment : undefined ,
129
144
query : { }
130
145
}
131
146
132
147
void resolveLocation ( notificationLocation ) . then ( ( resolvedLocation ) => {
133
- if ( resolvedLocation !== undefined ) {
148
+ if ( resolvedLocation ?. loc != null ) {
134
149
navigate ( resolvedLocation . loc )
135
150
} else {
136
- // Fallback navigation if resolution fails
137
- const urlString = `${ frontUrl } /${ workbenchId } /${ currentLocation . path [ 1 ] } /${ notificationId } /${ encodedObjectURI } `
138
- const urlObject = new URL ( urlString )
139
- navigate ( parseLocation ( urlObject ) )
151
+ navigateToUrl ( `${ workbenchId } /${ notificationParams . application } /${ notificationId } /${ encodedObjectURI } ` )
140
152
}
141
153
} ) . catch ( ( ) => {
142
- // Fallback to basic navigation if resolution fails
143
- const frontUrl = getMetadata ( presentation . metadata . FrontUrl ) ?? window . location . origin
144
- const location = getCurrentResolvedLocation ( )
145
- const urlString = `${ frontUrl } /${ workbenchId } /${ location . path [ 1 ] } /${ notificationParams . application ?? notificationId } `
146
- const urlObject = new URL ( urlString )
147
- navigate ( parseLocation ( urlObject ) )
154
+ navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
148
155
} )
149
156
} else {
150
- // Fallback to basic navigation for old notifications without object data
151
- const frontUrl = getMetadata ( presentation . metadata . FrontUrl ) ?? window . location . origin
152
- const location = getCurrentResolvedLocation ( )
153
- const urlString = `${ frontUrl } /${ workbenchId } /${ location . path [ 1 ] } /${ notificationParams . application ?? notificationId } `
154
- const urlObject = new URL ( urlString )
155
- navigate ( parseLocation ( urlObject ) )
157
+ // Fallback to basic notification navigation
158
+ navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
156
159
}
157
160
} )
158
161
0 commit comments