Wrap systemPreferences.subscribeNotification in darwin check

This commit is contained in:
Marquis Kurt 2019-08-05 20:28:43 -04:00
parent b9e1a0e6b5
commit f532c9b99e
No known key found for this signature in database
GPG Key ID: 725636D259F5402D
1 changed files with 10 additions and 7 deletions

View File

@ -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', () => {