Skip to content

Commit

Permalink
Guard macOS-only APIs
Browse files Browse the repository at this point in the history
Fixes #704
Closes #708
  • Loading branch information
sindresorhus committed Jan 9, 2019
1 parent 6e75dcd commit 04cb6a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ ipc.on('toggle-unread-threads-view', () => {
});

function setDarkMode() {
if (config.get('followSystemAppearance')) {
if (is.macos && config.get('followSystemAppearance')) {
document.documentElement.classList.toggle('dark-mode', api.systemPreferences.isDarkMode());
} else {
document.documentElement.classList.toggle('dark-mode', config.get('darkMode'));
}

setVibrancy();
}

Expand Down
19 changes: 11 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,17 @@ function createMainWindow() {
});
})();

ipcMain.on('set-vibrancy', () => {
mainWindow.setVibrancy('sidebar');
if (config.get('followSystemAppearance')) {
systemPreferences.setAppLevelAppearance(systemPreferences.isDarkMode() ? 'dark' : 'light');
} else {
systemPreferences.setAppLevelAppearance(config.get('darkMode') ? 'dark' : 'light');
}
});
if (is.macos) {
ipcMain.on('set-vibrancy', () => {
mainWindow.setVibrancy('sidebar');

if (config.get('followSystemAppearance')) {
systemPreferences.setAppLevelAppearance(systemPreferences.isDarkMode() ? 'dark' : 'light');
} else {
systemPreferences.setAppLevelAppearance(config.get('darkMode') ? 'dark' : 'light');
}
});
}

ipcMain.on('mute-notifications-toggled', (event, status) => {
setNotificationsMute(status);
Expand Down

0 comments on commit 04cb6a1

Please sign in to comment.