tabs/src/windows/SettingsWindow.ts

52 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-05-22 10:25:19 +02:00
import {Event} from "electron";
import path from "path";
import Window from "../Window";
import MainWindow from "./MainWindow";
import Meta from "../Meta";
2020-09-29 20:43:41 +02:00
import Config from "../Config";
2020-05-22 10:25:19 +02:00
export default class SettingsWindow extends Window {
2020-09-29 20:43:41 +02:00
public setup(): void {
2020-05-22 10:25:19 +02:00
super.setup({
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
webviewTag: true,
},
modal: true,
autoHideMenuBar: true,
height: 850,
});
const window = this.getWindow();
if (this.application.isDevMode()) {
window.webContents.openDevTools({
2020-09-29 20:43:41 +02:00
mode: 'right',
2020-05-22 10:25:19 +02:00
});
}
this.onIpc('syncSettings', () => {
window.webContents.send('current-version', this.application.getUpdater().getCurrentVersion());
window.webContents.send('config', this.config);
});
this.onIpc('checkForUpdates', () => {
this.application.getUpdater().checkForUpdates().then(updateInfo => {
window.webContents.send('updateStatus', typeof updateInfo === 'object', updateInfo);
}).catch(console.error);
});
2020-09-29 20:43:41 +02:00
this.onIpc('save-config', (e: Event, data: Config) => {
2020-05-22 10:25:19 +02:00
this.config.update(data);
this.config.save();
if (this.parent instanceof MainWindow) {
this.parent.syncData();
}
});
window.loadFile(path.resolve(Meta.RESOURCES_PATH, 'settings.html'))
.catch(console.error);
}
2020-09-29 20:43:41 +02:00
}