@@ -52,18 +52,15 @@ export class App {
52
52
}
53
53
set websocket_url ( url ) {
54
54
this . client . url = url ;
55
- this . client . disconnect ( ) . then ( ( ) => this . client . tryConnect ( ) ) ;
56
- if ( this . window ) this . window . send ( 'reset-has-connected' ) ;
55
+ if ( this . client . connected ) this . client . disconnect ( ) . then ( ( ) => this . client . tryConnect ( ) ) ;
56
+ // if (this.window) this.window.send('reset-has-connected');
57
57
}
58
58
59
59
async connected ( connection ) {
60
- log . info ( 'Connected to %s' , client . url ) ;
60
+ log . info ( 'Connected to %s' , client . url , client ) ;
61
61
62
62
if ( this . window ) this . window . send ( 'up' ) ;
63
63
64
- this . client . connection . getHomeSettings ( ) . then ( d => this . client . home_settings = d ) ;
65
- this . client . refreshAccessories ( ) ;
66
-
67
64
connection . on ( 'received-broadcast' , data => {
68
65
if ( this . window ) this . window . send ( 'b' , data ) ;
69
66
} ) ;
@@ -74,7 +71,7 @@ export class App {
74
71
this . constructor . menu . items [ 2 ] . enabled = true ;
75
72
76
73
this . constructor . tray . setContextMenu ( this . constructor . menu ) ;
77
- electron . app . dock . setMenu ( this . constructor . menu ) ;
74
+ if ( process . platform === 'darwin' ) electron . app . dock . setMenu ( this . constructor . menu ) ;
78
75
}
79
76
80
77
disconnected ( event ) {
@@ -88,7 +85,7 @@ export class App {
88
85
this . constructor . menu . items [ 2 ] . enabled = false ;
89
86
90
87
this . constructor . tray . setContextMenu ( this . constructor . menu ) ;
91
- electron . app . dock . setMenu ( this . constructor . menu ) ;
88
+ if ( process . platform === 'darwin' ) electron . app . dock . setMenu ( this . constructor . menu ) ;
92
89
}
93
90
94
91
handleUpdateCharateristic ( accessory_uuid , service_uuid , characteristic_uuid , details ) {
@@ -133,6 +130,9 @@ export class App {
133
130
134
131
log . info ( 'AuthenticatedUser' , authenticated_user ) ;
135
132
this . client . connection . authenticated_user = authenticated_user ;
133
+
134
+ this . client . connection . getHomeSettings ( ) . then ( d => this . client . home_settings = d ) ;
135
+ this . client . refreshAccessories ( ) ;
136
136
}
137
137
} else {
138
138
event . sender . send ( 'r' , { messageid, response : null } ) ;
@@ -164,7 +164,7 @@ export class App {
164
164
this . window . once ( 'ready-to-show' , ( ) => {
165
165
this . window . show ( ) ;
166
166
167
- electron . app . dock . show ( ) ;
167
+ if ( process . platform === 'darwin' ) electron . app . dock . show ( ) ;
168
168
} ) ;
169
169
170
170
// Emitted when the window is closed
@@ -174,7 +174,7 @@ export class App {
174
174
// when you should delete the corresponding element
175
175
this . window = null ;
176
176
177
- if ( ! BrowserWindow . getAllWindows ( ) . length ) electron . app . dock . hide ( ) ;
177
+ if ( process . platform === 'darwin' && ! BrowserWindow . getAllWindows ( ) . length ) electron . app . dock . hide ( ) ;
178
178
} ) ;
179
179
}
180
180
@@ -193,7 +193,7 @@ export class App {
193
193
] ) ;
194
194
195
195
this . tray . setContextMenu ( this . menu ) ;
196
- electron . app . dock . setMenu ( this . menu ) ;
196
+ if ( process . platform === 'darwin' ) electron . app . dock . setMenu ( this . menu ) ;
197
197
198
198
session . defaultSession . webRequest . onBeforeSendHeaders ( this . onBeforeSendHeaders . bind ( this ) ) ;
199
199
@@ -206,7 +206,7 @@ export class App {
206
206
const url = await this . storage . getItem ( 'URL' ) ;
207
207
if ( url ) app . url = url ;
208
208
209
- app . client . tryConnect ( ) ;
209
+ await app . client . tryConnect ( ) ;
210
210
211
211
log . info ( 'Ready, creating window' ) ;
212
212
@@ -239,7 +239,7 @@ export class App {
239
239
this . preferences_window . once ( 'ready-to-show' , ( ) => {
240
240
this . preferences_window . show ( ) ;
241
241
242
- electron . app . dock . show ( ) ;
242
+ if ( process . platform === 'darwin' ) electron . app . dock . show ( ) ;
243
243
} ) ;
244
244
245
245
// Emitted when the window is closed
@@ -249,7 +249,7 @@ export class App {
249
249
// when you should delete the corresponding element
250
250
this . preferences_window = null ;
251
251
252
- if ( ! BrowserWindow . getAllWindows ( ) . length ) electron . app . dock . hide ( ) ;
252
+ if ( process . platform === 'darwin' && ! BrowserWindow . getAllWindows ( ) . length ) electron . app . dock . hide ( ) ;
253
253
} ) ;
254
254
}
255
255
@@ -264,7 +264,7 @@ export class App {
264
264
}
265
265
}
266
266
267
- electron . app . dock . hide ( ) ;
267
+ if ( process . platform === 'darwin' ) electron . app . dock . hide ( ) ;
268
268
269
269
export const app = new App ( ) ;
270
270
const client = app . client ;
@@ -293,7 +293,9 @@ ipcMain.on('set-preferences', async (event, data) => {
293
293
}
294
294
} ) ;
295
295
296
- electron . systemPreferences . subscribeNotification ( 'AppleInterfaceThemeChangedNotification' , ( ) => {
296
+ if ( process . platform === 'darwin' ) {
297
+ electron . systemPreferences . subscribeNotification ( 'AppleInterfaceThemeChangedNotification' , ( ) => {
298
+ electron . systemPreferences . setAppLevelAppearance ( electron . systemPreferences . isDarkMode ( ) ? 'dark' : 'light' ) ;
299
+ } ) ;
297
300
electron . systemPreferences . setAppLevelAppearance ( electron . systemPreferences . isDarkMode ( ) ? 'dark' : 'light' ) ;
298
- } ) ;
299
- electron . systemPreferences . setAppLevelAppearance ( electron . systemPreferences . isDarkMode ( ) ? 'dark' : 'light' ) ;
301
+ }
0 commit comments