@@ -18,13 +18,16 @@ import {
18
18
} from '@hcengineering/ui'
19
19
import { handleDownloadItem } from '@hcengineering/desktop-downloads'
20
20
import notification , { notificationId } from '@hcengineering/notification'
21
+ import { inboxId } from '@hcengineering/inbox'
21
22
import { workbenchId , logOut } from '@hcengineering/workbench'
23
+ import { encodeObjectURI } from '@hcengineering/view'
24
+ import { resolveLocation } from '@hcengineering/notification-resources'
22
25
23
26
import { isOwnerOrMaintainer } from '@hcengineering/core'
24
27
import { configurePlatform } from './platform'
25
28
import { setupTitleBarMenu } from './titleBarMenu'
26
29
import { defineScreenShare , defineGetDisplayMedia } from './screenShare'
27
- import { CommandLogout , CommandSelectWorkspace , CommandOpenSettings , CommandOpenInbox , CommandOpenPlanner , CommandOpenOffice , CommandOpenApplication , LaunchApplication } from './types'
30
+ import { CommandLogout , CommandSelectWorkspace , CommandOpenSettings , CommandOpenInbox , CommandOpenPlanner , CommandOpenOffice , CommandOpenApplication , LaunchApplication , NotificationParams } from './types'
28
31
import { ipcMainExposed } from './typesUtils'
29
32
import { themeStore } from '@hcengineering/theme'
30
33
@@ -156,13 +159,46 @@ window.addEventListener('DOMContentLoaded', () => {
156
159
navigate ( parseLocation ( urlObject ) )
157
160
} )
158
161
159
- ipcMain . handleNotificationNavigation ( ( application ) => {
160
- // For now navigate only to Inbox
162
+ function navigateToUrl ( path : string ) : void {
161
163
const frontUrl = getMetadata ( presentation . metadata . FrontUrl ) ?? window . location . origin
162
- const location = getCurrentResolvedLocation ( )
163
- const urlString = `${ frontUrl } /${ workbenchId } /${ location . path [ 1 ] } /${ application ?? notificationId } `
164
- const urlObject = new URL ( urlString )
164
+ const urlObject = new URL ( `${ frontUrl } /${ path } ` )
165
165
navigate ( parseLocation ( urlObject ) )
166
+ }
167
+
168
+ function getBasicNotificationPath ( notificationParams : NotificationParams ) : string {
169
+ return `${ workbenchId } /${ notificationParams . application ?? notificationId } /${ notificationId } `
170
+ }
171
+
172
+ ipcMain . handleNotificationNavigation ( ( notificationParams : NotificationParams ) => {
173
+ // Support for new inbox with cardId (card-based)
174
+ if ( notificationParams . cardId != null ) {
175
+ const currentLocation = getCurrentResolvedLocation ( )
176
+ navigateToUrl ( `${ workbenchId } /${ currentLocation . path [ 1 ] } /${ inboxId } /${ notificationParams . cardId } ` )
177
+ return
178
+ }
179
+
180
+ // Support for old inbox with objectId + objectClass (legacy)
181
+ if ( notificationParams . objectId != null && notificationParams . objectClass != null ) {
182
+ const encodedObjectURI = encodeObjectURI ( notificationParams . objectId , notificationParams . objectClass )
183
+ const notificationLocation = {
184
+ path : [ workbenchId , notificationParams . application , notificationId , encodedObjectURI ] ,
185
+ fragment : undefined ,
186
+ query : { }
187
+ }
188
+
189
+ void resolveLocation ( notificationLocation ) . then ( ( resolvedLocation ) => {
190
+ if ( resolvedLocation ?. loc != null ) {
191
+ navigate ( resolvedLocation . loc )
192
+ } else {
193
+ navigateToUrl ( `${ workbenchId } /${ notificationParams . application } /${ notificationId } /${ encodedObjectURI } ` )
194
+ }
195
+ } ) . catch ( ( ) => {
196
+ navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
197
+ } )
198
+ } else {
199
+ // Fallback to basic notification navigation
200
+ navigateToUrl ( getBasicNotificationPath ( notificationParams ) )
201
+ }
166
202
} )
167
203
168
204
ipcMain . handleUpdateDownloadProgress ( ( progress ) => {
0 commit comments