refactor: Use invoke for ipc to change global header

This commit is contained in:
AkiraFukushima 2020-11-29 22:42:16 +09:00
parent 69ac0bb3e9
commit 61602afcf9
2 changed files with 11 additions and 21 deletions

View File

@ -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) => {

View File

@ -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