Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
minHeight: 200,
alwaysOnTop: config.get('alwaysOnTop'),
titleBarStyle: 'hiddenInset',
autoHideMenuBar: config.get('autoHideMenuBar'),
darkTheme: isDarkMode, // GTK+3
webPreferences: {
preload: path.join(__dirname, 'browser.js'),
contextIsolation: true,
plugins: true
}
});
setUserLocale();
initRequestsFiltering();
darkMode.onChange(() => {
win.webContents.send('set-dark-mode');
});
if (is.macos) {
win.setSheetOffset(40);
}
win.loadURL(mainURL);
win.on('close', event => {
if (config.get('quitOnWindowClose')) {
app.quit();
return;
}
// Workaround for https://github.com/electron/electron/issues/20263
dispatchThunk(openOverlay("statistics"));
});
// Screen lock
// Lock diary when screen is locked
if (is.macos || is.windows) {
remote.powerMonitor.on("lock-screen", (): void => {
dispatchThunk(lock());
});
}
// Theme
// Listen to system theme changes and update the app theme accordingly
darkMode.onChange((): void => {
dispatchThunk(setTheme(darkMode.isEnabled ? "dark" : "light"));
});
}
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
if (darkMode.isEnabled) {
if (mainWindow) {
mainWindow.webContents.send('Dark mode', {
darkmode: systemPreferences.isDarkMode()
})
}
}
darkMode.onChange(() => {
if (mainWindow) {
mainWindow.webContents.send('Dark mode', {
darkmode: darkMode.isEnabled
})
}
})
ipcMain.on('article-selected', (event, status) => {
const menuItemViewBrowser = menu.getMenuItemById('view-browser')
const menuItemToggleFavourite = menu.getMenuItemById('toggle-favourite')
const menuItemSaveOffline = menu.getMenuItemById('save-offline')
const menuItemToggleRead = menu.getMenuItemById('toggle-read')
menuItemViewBrowser.enabled = true
menuItemToggleFavourite.enabled = true
menuItemSaveOffline.enabled = true
bindListeners() {
this.addSubscription(
new Disposable(darkMode.onChange(this.handleDarkModeChange.bind(this)))
)
ipc.on('close-via-menu', window.close)
this.addSubscription(
new Disposable(() => ipc.removeListener('close-via-menu', window.close))
)
ipc.answerMain('close', () => {
return new Promise(resolve => {
this.cleanup()
resolve()
})
})
}
}
constructor() {
super();
this.views = new Cycled(appViews);
this.setTheme(this.state.theme);
this.coinPrices = [];
darkMode.onChange(() => {
this.setTheme(this.state.theme);
});
}