@@ -22,14 +22,16 @@ import { ProgressInfo, UpdateInfo } from 'electron-updater'
22
22
import WinBadge from 'electron-windows-badge'
23
23
import * as path from 'path'
24
24
25
- import { Config , MenuBarAction , NotificationParams , StandardMenuCommandLogout , StandardMenuCommandSelectWorkspace , StandardMenuCommandOpenSettings } from '../ui/types'
25
+ import { Config , MenuBarAction , NotificationParams } from '../ui/types'
26
26
import { getOptions } from './args'
27
27
import { addMenus } from './standardMenu'
28
28
import { dipatchMenuBarAction } from './customMenu'
29
29
import { addPermissionHandlers } from './permissions'
30
30
import autoUpdater from './updater'
31
31
import { generateId } from '@hcengineering/core'
32
32
import { DownloadItem } from '@hcengineering/desktop-downloads'
33
+ import { setupWindowsSpecific } from './windowsSpecificSetup'
34
+
33
35
34
36
let mainWindow : BrowserWindow | undefined
35
37
let winBadge : any
@@ -39,7 +41,7 @@ const isWindows = process.platform === 'win32'
39
41
const isDev = process . env . NODE_ENV === 'development'
40
42
41
43
const sessionPartition = ! isDev ? 'persist:huly' : 'persist:huly_dev'
42
- const iconKey = path . join ( app . getAppPath ( ) , 'dist' , 'ui' , 'public' , 'AppIcon.png' )
44
+ const iconKey = path . join ( app . getAppPath ( ) , 'dist' , 'ui' , 'public' , isWindows ? 'AppIcon.ico' : 'AppIcon.png' )
43
45
const preloadScriptPath = path . join ( app . getAppPath ( ) , 'dist' , 'main' , 'preload.js' )
44
46
45
47
const defaultWidth = 1440
@@ -200,7 +202,7 @@ function handleAuthRedirects (window: BrowserWindow): void {
200
202
}
201
203
202
204
function handleWillDownload ( window : BrowserWindow ) : void {
203
- window . webContents . session . on ( 'will-download' , ( event , item ) => {
205
+ window . webContents . session . on ( 'will-download' , ( _event , item ) => {
204
206
const key = generateId ( )
205
207
206
208
const notifyDownloadUpdated = ( ) : void => {
@@ -303,10 +305,14 @@ const createWindow = async (): Promise<void> => {
303
305
}
304
306
}
305
307
306
- if ( false == isWindows ) {
307
- addMenus ( ( cmd : string , ...args : any [ ] ) => {
308
- mainWindow ?. webContents . send ( cmd , ...args )
309
- } )
308
+ function sendCommand ( cmd : string , ...args : any [ ] ) : void {
309
+ mainWindow ?. webContents . send ( cmd , ...args )
310
+ }
311
+
312
+ if ( isWindows ) {
313
+ setupWindowsSpecific ( sendCommand )
314
+ } else {
315
+ addMenus ( sendCommand )
310
316
}
311
317
312
318
contextMenu ( {
@@ -315,7 +321,7 @@ contextMenu({
315
321
showSelectAll : false
316
322
} )
317
323
318
- ipcMain . on ( 'set-badge' , ( event , badge : number ) => {
324
+ ipcMain . on ( 'set-badge' , ( _event : any , badge : number ) => {
319
325
app . dock ?. setBadge ( badge > 0 ? `${ badge } ` : '' )
320
326
app . badgeCount = badge
321
327
@@ -324,11 +330,11 @@ ipcMain.on('set-badge', (event, badge: number) => {
324
330
}
325
331
} )
326
332
327
- ipcMain . on ( 'dock-bounce' , ( event ) => {
333
+ ipcMain . on ( 'dock-bounce' , ( _event : any ) => {
328
334
app . dock ?. bounce ( 'informational' )
329
335
} )
330
336
331
- ipcMain . on ( 'send-notification' , ( event , notificationParams : NotificationParams ) => {
337
+ ipcMain . on ( 'send-notification' , ( _event : any , notificationParams : NotificationParams ) => {
332
338
if ( Notification . isSupported ( ) ) {
333
339
const notification = new Notification ( notificationParams )
334
340
@@ -341,13 +347,13 @@ ipcMain.on('send-notification', (event, notificationParams: NotificationParams)
341
347
}
342
348
} )
343
349
344
- ipcMain . on ( 'set-title' , ( event , title ) => {
350
+ ipcMain . on ( 'set-title' , ( event : any , title : string ) => {
345
351
const webContents = event . sender
346
352
const window = BrowserWindow . fromWebContents ( webContents )
347
353
window ?. setTitle ( title )
348
354
} )
349
355
350
- ipcMain . on ( 'set-combined-config' , ( event , config : Config ) => {
356
+ ipcMain . on ( 'set-combined-config' , ( _event : any , config : Config ) => {
351
357
log . info ( 'Config set: ' , config )
352
358
353
359
setupCookieHandler ( config )
@@ -363,7 +369,7 @@ ipcMain.on('set-combined-config', (event, config: Config) => {
363
369
void autoUpdater . checkForUpdatesAndNotify ( )
364
370
} )
365
371
366
- ipcMain . handle ( 'get-main-config' , ( event , path ) => {
372
+ ipcMain . handle ( 'get-main-config' , ( _event : any , _path : any ) => {
367
373
const cfg = {
368
374
CONFIG_URL : process . env . CONFIG_URL ?? '' ,
369
375
FRONT_URL ,
@@ -373,11 +379,11 @@ ipcMain.handle('get-main-config', (event, path) => {
373
379
}
374
380
return cfg
375
381
} )
376
- ipcMain . handle ( 'get-host' , ( event , path ) => {
382
+ ipcMain . handle ( 'get-host' , ( _event : any , _path : any ) => {
377
383
return new URL ( FRONT_URL ) . host
378
384
} )
379
385
380
- ipcMain . on ( 'set-front-cookie' , function ( event , host : string , name : string , value : string ) {
386
+ ipcMain . on ( 'set-front-cookie' , function ( event : any , host : string , name : string , value : string ) {
381
387
const webContents = event . sender
382
388
const win = BrowserWindow . fromWebContents ( webContents )
383
389
const cv : CookiesSetDetails = {
@@ -428,7 +434,7 @@ if (!gotTheLock) {
428
434
ipcMain . handle ( 'get-screen-access' , ( ) => systemPreferences . getMediaAccessStatus ( 'screen' ) === 'granted' )
429
435
ipcMain . handle ( 'get-screen-sources' , ( ) => {
430
436
return desktopCapturer . getSources ( { types : [ 'window' , 'screen' ] , fetchWindowIcons : true , thumbnailSize : { width : 225 , height : 135 } } ) . then ( async sources => {
431
- return sources . map ( source => {
437
+ return sources . map ( ( source : any ) => {
432
438
return {
433
439
...source ,
434
440
appIconURL : source . appIcon ?. toDataURL ( ) ,
@@ -490,7 +496,7 @@ autoUpdater.on('update-available', (info: UpdateInfo) => {
490
496
defaultId : 0 ,
491
497
message : `A new version ${ info . version } is available and it is required to continue. It will be downloaded and installed automatically.`
492
498
} )
493
- . then ( ( { response } ) => {
499
+ . then ( ( { response } : any ) => {
494
500
log . info ( `Update dialog exit code: ${ response } ` ) // eslint-disable-line no-console
495
501
496
502
if ( response !== 0 ) {
@@ -513,7 +519,7 @@ function setDownloadProgress (percent: number): void {
513
519
mainWindow . webContents . send ( 'handle-update-download-progress' , percent )
514
520
}
515
521
516
- autoUpdater . on ( 'update-downloaded' , ( info ) => {
522
+ autoUpdater . on ( 'update-downloaded' , ( _info : any ) => {
517
523
// We have listeners that prevents the app from being exited on mac
518
524
app . removeAllListeners ( 'window-all-closed' )
519
525
mainWindow ?. removeAllListeners ( 'close' )
0 commit comments