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
|
// hashtag
|
||||||
ipcMain.on('save-hashtag', (event: IpcMainEvent, tag: string) => {
|
ipcMain.handle('save-hashtag', async (_: IpcMainInvokeEvent, tag: string) => {
|
||||||
const hashtags = new Hashtags(hashtagsDB)
|
const hashtags = new Hashtags(hashtagsDB)
|
||||||
hashtags
|
await hashtags.insertTag(tag)
|
||||||
.insertTag(tag)
|
|
||||||
.then(() => {
|
|
||||||
event.sender.send('response-save-hashtag')
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
log.error(err)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('list-hashtags', (event: IpcMainEvent) => {
|
ipcMain.on('list-hashtags', (event: IpcMainEvent) => {
|
||||||
|
|
|
@ -18,11 +18,9 @@ export type HashtagModuleState = HashtagModule & HashtagState
|
||||||
const state = (): HashtagState => ({})
|
const state = (): HashtagState => ({})
|
||||||
|
|
||||||
const actions: ActionTree<HashtagState, RootState> = {
|
const actions: ActionTree<HashtagState, RootState> = {
|
||||||
saveTag: ({ dispatch }, tag: string) => {
|
saveTag: async ({ dispatch }, tag: string) => {
|
||||||
win.ipcRenderer.once('response-save-hashtag', () => {
|
await win.ipcRenderer.invoke('save-hashtag', tag)
|
||||||
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
||||||
})
|
|
||||||
win.ipcRenderer.send('save-hashtag', tag)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue