refactor: Use invoke for ipc to save hashtag

This commit is contained in:
AkiraFukushima 2020-11-29 22:49:10 +09:00
parent 5d4428038b
commit b3c03b1406
2 changed files with 5 additions and 14 deletions

View File

@ -989,16 +989,9 @@ ipcMain.handle('change-language', async (_: IpcMainInvokeEvent, value: string) =
})
// hashtag
ipcMain.on('save-hashtag', (event: IpcMainEvent, tag: string) => {
ipcMain.handle('save-hashtag', async (_: IpcMainInvokeEvent, tag: string) => {
const hashtags = new Hashtags(hashtagsDB)
hashtags
.insertTag(tag)
.then(() => {
event.sender.send('response-save-hashtag')
})
.catch(err => {
log.error(err)
})
await hashtags.insertTag(tag)
})
ipcMain.on('list-hashtags', (event: IpcMainEvent) => {

View File

@ -18,11 +18,9 @@ export type HashtagModuleState = HashtagModule & HashtagState
const state = (): HashtagState => ({})
const actions: ActionTree<HashtagState, RootState> = {
saveTag: ({ dispatch }, tag: string) => {
win.ipcRenderer.once('response-save-hashtag', () => {
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
})
win.ipcRenderer.send('save-hashtag', tag)
saveTag: async ({ dispatch }, tag: string) => {
await win.ipcRenderer.invoke('save-hashtag', tag)
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
}
}