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
|
||||
})
|
||||
|
||||
ipcMain.on('change-global-header', (event: IpcMainEvent, value: boolean) => {
|
||||
ipcMain.handle('change-global-header', async (_: IpcMainInvokeEvent, value: boolean) => {
|
||||
const preferences = new Preferences(preferencesDBPath)
|
||||
preferences
|
||||
.update({
|
||||
const conf = await preferences.update({
|
||||
state: {
|
||||
hideGlobalHeader: value
|
||||
}
|
||||
})
|
||||
.then(conf => {
|
||||
event.sender.send('response-change-global-header', conf)
|
||||
})
|
||||
.catch(err => {
|
||||
log.error(err)
|
||||
})
|
||||
return conf
|
||||
})
|
||||
|
||||
ipcMain.on('get-global-header', (event: IpcMainEvent) => {
|
||||
|
|
|
@ -104,14 +104,10 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
|
|||
})
|
||||
})
|
||||
},
|
||||
switchHide: ({ dispatch }, hide: boolean): Promise<boolean> => {
|
||||
return new Promise(resolve => {
|
||||
win.ipcRenderer.send('change-global-header', hide)
|
||||
win.ipcRenderer.once('response-change-global-header', () => {
|
||||
switchHide: async ({ dispatch }, hide: boolean): Promise<boolean> => {
|
||||
await win.ipcRenderer.invoke('change-global-header', hide)
|
||||
dispatch('loadHide')
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
return true
|
||||
},
|
||||
startUserStreamings: ({ state }): Promise<{}> => {
|
||||
// @ts-ignore
|
||||
|
|
Loading…
Reference in New Issue