refactor: Use invoke for ipc to get global header
This commit is contained in:
parent
61602afcf9
commit
2b84a9402e
|
@ -950,11 +950,10 @@ ipcMain.handle('change-global-header', async (_: IpcMainInvokeEvent, value: bool
|
|||
return conf
|
||||
})
|
||||
|
||||
ipcMain.on('get-global-header', (event: IpcMainEvent) => {
|
||||
ipcMain.handle('get-global-header', async (_: IpcMainInvokeEvent) => {
|
||||
const preferences = new Preferences(preferencesDBPath)
|
||||
preferences.load().then(conf => {
|
||||
event.sender.send('response-get-global-header', conf.state.hideGlobalHeader)
|
||||
})
|
||||
const conf = await preferences.load()
|
||||
return conf.state.hideGlobalHeader
|
||||
})
|
||||
|
||||
// proxy
|
||||
|
|
|
@ -95,14 +95,10 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
|
|||
win.ipcRenderer.removeAllListeners('change-account')
|
||||
return true
|
||||
},
|
||||
loadHide: ({ commit }): Promise<boolean> => {
|
||||
return new Promise(resolve => {
|
||||
win.ipcRenderer.send('get-global-header')
|
||||
win.ipcRenderer.once('response-get-global-header', (_, hide: boolean) => {
|
||||
commit(MUTATION_TYPES.CHANGE_HIDE, hide)
|
||||
resolve(hide)
|
||||
})
|
||||
})
|
||||
loadHide: async ({ commit }): Promise<boolean> => {
|
||||
const hide: boolean = await win.ipcRenderer.invoke('get-global-header')
|
||||
commit(MUTATION_TYPES.CHANGE_HIDE, hide)
|
||||
return hide
|
||||
},
|
||||
switchHide: async ({ dispatch }, hide: boolean): Promise<boolean> => {
|
||||
await win.ipcRenderer.invoke('change-global-header', hide)
|
||||
|
|
Loading…
Reference in New Issue