Wrap systemPreferences.subscribeNotification in darwin check
This commit is contained in:
parent
b9e1a0e6b5
commit
f532c9b99e
|
@ -23,6 +23,7 @@ protocol.registerSchemesAsPrivileged([
|
|||
|
||||
/**
|
||||
* Determine whether the desktop app is on macOS
|
||||
* - Returns: Boolean of whether platform is Darwin
|
||||
*/
|
||||
function darwin() {
|
||||
return process.platform === "darwin";
|
||||
|
@ -144,14 +145,16 @@ function createWindow() {
|
|||
|
||||
// Load the main app and open the index page.
|
||||
mainWindow.loadURL("hyperspace://hyperspace/app/");
|
||||
|
||||
|
||||
// Watch for a change in macOS's dark mode and reload the window to apply changes
|
||||
systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => {
|
||||
if (mainWindow != null) {
|
||||
mainWindow.setVibrancy(systemPreferences.isDarkMode()? "ultra-dark": "light");
|
||||
mainWindow.webContents.reload();
|
||||
}
|
||||
})
|
||||
if (darwin()) {
|
||||
systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => {
|
||||
if (mainWindow != null) {
|
||||
mainWindow.setVibrancy(systemPreferences.isDarkMode()? "ultra-dark": "light");
|
||||
mainWindow.webContents.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the window when closed
|
||||
mainWindow.on('closed', () => {
|
||||
|
|
Loading…
Reference in New Issue