refactor: Use invoke for ipc to save hashtag
This commit is contained in:
parent
5d4428038b
commit
b3c03b1406
|
@ -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) => {
|
||||
|
|
|
@ -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', () => {
|
||||
saveTag: async ({ dispatch }, tag: string) => {
|
||||
await win.ipcRenderer.invoke('save-hashtag', tag)
|
||||
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
||||
})
|
||||
win.ipcRenderer.send('save-hashtag', tag)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue