1
1
// Scrips are moved to scripts/renderer/preload.js so node integration can be disabled
2
2
// in the application window.
3
+
4
+ /* eslint-disable no-console */
5
+
3
6
/**
4
7
* Class responsible for initializing the main ARC elements
5
8
* and setup base options.
@@ -94,6 +97,7 @@ class ArcInit {
94
97
ipc . on ( 'app-navigate' , this . _appNavHandler . bind ( this ) ) ;
95
98
ipc . on ( 'popup-app-menu-opened' , this . _popupMenuOpened . bind ( this ) ) ;
96
99
ipc . on ( 'popup-app-menu-closed' , this . _popupMenuClosed . bind ( this ) ) ;
100
+ ipc . on ( 'system-theme-changed' , this . _systemThemeChangeHandler . bind ( this ) ) ;
97
101
}
98
102
/**
99
103
* Requests initial state information from the main process for current
@@ -145,9 +149,9 @@ class ArcInit {
145
149
throw e ;
146
150
}
147
151
if ( this . initConfig . darkMode ) {
148
- cnf . theme = 'advanced-rest-client/arc-electron-dark-theme' ;
152
+ cnf . theme = '@ advanced-rest-client/arc-electron-dark-theme' ;
149
153
}
150
- if ( cnf . theme === 'advanced-rest-client/arc-electron-anypoint-theme' ) {
154
+ if ( cnf . theme === '@ advanced-rest-client/arc-electron-anypoint-theme' ) {
151
155
const app = this . app ;
152
156
app . compatibility = true ;
153
157
}
@@ -177,6 +181,7 @@ class ArcInit {
177
181
if ( this . created ) {
178
182
return Promise . resolve ( ) ;
179
183
}
184
+ /* eslint-disable-next-line import/no-unresolved */
180
185
await import ( 'web-module://src/arc-electron.js' ) ;
181
186
const app = document . createElement ( 'arc-electron' ) ;
182
187
app . id = 'app' ;
@@ -237,7 +242,7 @@ class ArcInit {
237
242
*/
238
243
commandHandler ( e , action , ...args ) {
239
244
// console.info('Renderer command handled: ', action);
240
- const app = this . app ;
245
+ const { app } = this ;
241
246
switch ( action ) {
242
247
case 'show-settings' : app . openSettings ( ) ; break ;
243
248
case 'about' : app . openAbout ( ) ; break ;
@@ -262,6 +267,7 @@ class ArcInit {
262
267
case 'open-onboarding' : app . openOnboarding ( ) ; break ;
263
268
case 'open-workspace-details' : app . openWorkspaceDetails ( ) ; break ;
264
269
case 'export-workspace' : this . exportWorkspace ( ) ; break ;
270
+ case 'open-client-certificates' : app . openClientCertificates ( ) ; break ;
265
271
default :
266
272
console . warn ( 'Unknown command' , action , args ) ;
267
273
}
@@ -504,6 +510,26 @@ class ArcInit {
504
510
const workspace = this . app . workspace . serializeWorkspace ( ) ;
505
511
return await this . fs . exportFileData ( workspace , 'application/json' , 'arc-workspace.arc' ) ;
506
512
}
513
+ /**
514
+ * Handler for system theme change event dispatche in the IO thread.
515
+ * Updates theme depending on current setting.
516
+ *
517
+ * @param {Event } e
518
+ * @param {Boolean } isDarkMode true when Electron detected dark mode
519
+ * @return {Promise }
520
+ */
521
+ async _systemThemeChangeHandler ( e , isDarkMode ) {
522
+ const theme = isDarkMode ?
523
+ '@advanced-rest-client/arc-electron-dark-theme' :
524
+ '@advanced-rest-client/arc-electron-default-theme' ;
525
+ const app = this . app ;
526
+ app . compatibility = false ;
527
+ try {
528
+ await this . themeManager . loadTheme ( theme ) ;
529
+ } catch ( e ) {
530
+ console . error ( e ) ;
531
+ }
532
+ }
507
533
}
508
534
509
535
const initScript = new ArcInit ( ) ;
0 commit comments