synchronize config saves between windows

This commit is contained in:
Eugene Pankov
2022-05-28 12:35:32 +02:00
parent 296188c45e
commit 8c4c07c39b
6 changed files with 96 additions and 80 deletions

View File

@@ -6,7 +6,7 @@ import * as path from 'path'
import * as fs from 'fs'
import { Subject, throttleTime } from 'rxjs'
import { loadConfig } from './config'
import { saveConfig } from './config'
import { Window, WindowOptions } from './window'
import { pluginManager } from './pluginManager'
import { PTYManager } from './pty'
@@ -23,10 +23,10 @@ export class Application {
private windows: Window[] = []
private globalHotkey$ = new Subject<void>()
private quitRequested = false
private configStore: any
userPluginsPath: string
constructor () {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor (private configStore: any) {
remote.initialize()
this.useBuiltinGraphics()
this.ptyManager.init(this)
@@ -36,6 +36,10 @@ export class Application {
this.configStore = config
})
ipcMain.on('app:save-config', (_event, data) => {
saveConfig(data)
})
ipcMain.on('app:register-global-hotkey', (_event, specs) => {
globalShortcut.unregisterAll()
for (const spec of specs) {
@@ -63,7 +67,6 @@ export class Application {
}
})
this.configStore = loadConfig()
if (process.platform === 'linux') {
app.commandLine.appendSwitch('no-sandbox')
if (((this.configStore.appearance || {}).opacity || 1) !== 1) {
@@ -111,7 +114,7 @@ export class Application {
}
async newWindow (options?: WindowOptions): Promise<Window> {
const window = new Window(this, options)
const window = new Window(this, this.configStore, options)
this.windows.push(window)
if (this.windows.length === 1){
window.makeMain()