refactor: Use invoke for ipc to change global header
This commit is contained in:
parent
69ac0bb3e9
commit
61602afcf9
|
@ -940,20 +940,14 @@ ipcMain.handle('get-collapse', async (_: IpcMainInvokeEvent) => {
|
||||||
return conf.state.collapse
|
return conf.state.collapse
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('change-global-header', (event: IpcMainEvent, value: boolean) => {
|
ipcMain.handle('change-global-header', async (_: IpcMainInvokeEvent, value: boolean) => {
|
||||||
const preferences = new Preferences(preferencesDBPath)
|
const preferences = new Preferences(preferencesDBPath)
|
||||||
preferences
|
const conf = await preferences.update({
|
||||||
.update({
|
|
||||||
state: {
|
state: {
|
||||||
hideGlobalHeader: value
|
hideGlobalHeader: value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(conf => {
|
return conf
|
||||||
event.sender.send('response-change-global-header', conf)
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
log.error(err)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('get-global-header', (event: IpcMainEvent) => {
|
ipcMain.on('get-global-header', (event: IpcMainEvent) => {
|
||||||
|
|
|
@ -104,14 +104,10 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
switchHide: ({ dispatch }, hide: boolean): Promise<boolean> => {
|
switchHide: async ({ dispatch }, hide: boolean): Promise<boolean> => {
|
||||||
return new Promise(resolve => {
|
await win.ipcRenderer.invoke('change-global-header', hide)
|
||||||
win.ipcRenderer.send('change-global-header', hide)
|
|
||||||
win.ipcRenderer.once('response-change-global-header', () => {
|
|
||||||
dispatch('loadHide')
|
dispatch('loadHide')
|
||||||
resolve(true)
|
return true
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
startUserStreamings: ({ state }): Promise<{}> => {
|
startUserStreamings: ({ state }): Promise<{}> => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
Loading…
Reference in New Issue