| 
									
										
										
										
											2017-10-20 23:43:20 -04:00
										 |  |  | 'use strict'; | 
					
						
							| 
									
										
										
										
											2018-01-28 22:18:14 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-24 14:42:03 +01:00
										 |  |  | const {app, globalShortcut} = require('electron'); | 
					
						
							| 
									
										
										
										
											2019-03-31 11:21:44 +02:00
										 |  |  | const sqlInit = require('./src/services/sql_init'); | 
					
						
							| 
									
										
										
										
											2018-11-21 11:01:03 +01:00
										 |  |  | const appIconService = require('./src/services/app_icon'); | 
					
						
							| 
									
										
										
										
											2019-12-24 14:42:03 +01:00
										 |  |  | const windowService = require('./src/services/window'); | 
					
						
							| 
									
										
										
										
											2017-10-20 23:43:20 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Adds debug features like hotkeys for triggering dev tools and reload
 | 
					
						
							|  |  |  | require('electron-debug')(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-21 11:01:03 +01:00
										 |  |  | appIconService.installLocalAppIcon(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-18 22:19:07 -05:00
										 |  |  | require('electron-dl')({ saveAs: true }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-20 23:43:20 -04:00
										 |  |  | app.on('window-all-closed', () => { | 
					
						
							|  |  |  |     if (process.platform !== 'darwin') { | 
					
						
							|  |  |  |         app.quit(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-13 20:28:14 +01:00
										 |  |  |     else if (process.platform === 'win32') { | 
					
						
							|  |  |  |         app.exit(0); // attempt to fix the issue when app.quite() won't terminate processes on windows
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-10-20 23:43:20 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-21 21:12:07 +01:00
										 |  |  | app.on('ready', async () => { | 
					
						
							| 
									
										
										
										
											2021-04-19 22:33:58 +02:00
										 |  |  | //    app.setAppUserModelId('com.github.zadam.trilium');
 | 
					
						
							| 
									
										
										
										
											2019-11-21 21:12:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-19 22:09:49 +01:00
										 |  |  |     // if db is not initialized -> setup process
 | 
					
						
							|  |  |  |     // if db is initialized, then we need to wait until the migration process is finished
 | 
					
						
							|  |  |  |     if (await sqlInit.isDbInitialized()) { | 
					
						
							| 
									
										
										
										
											2019-12-24 14:42:03 +01:00
										 |  |  |         await sqlInit.dbReady; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         await windowService.createMainWindow(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         await windowService.createSetupWindow(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-21 21:12:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-27 20:28:27 +01:00
										 |  |  |     await windowService.registerGlobalShortcuts(); | 
					
						
							| 
									
										
										
										
											2018-02-12 23:53:00 -05:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.on('will-quit', () => { | 
					
						
							|  |  |  |     globalShortcut.unregisterAll(); | 
					
						
							| 
									
										
										
										
											2017-10-20 23:43:20 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-08 17:44:34 +01:00
										 |  |  | // this is to disable electron warning spam in the dev console (local development only)
 | 
					
						
							| 
									
										
										
										
											2020-02-08 10:40:58 +01:00
										 |  |  | process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-31 08:03:25 -05:00
										 |  |  | require('./src/www'); |