refactor: Use invoke for ipc to remove hashtag
This commit is contained in:
parent
778ed6f642
commit
0cb08601f8
|
@ -1000,16 +1000,9 @@ ipcMain.handle('list-hashtags', async (_: IpcMainInvokeEvent) => {
|
||||||
return tags
|
return tags
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('remove-hashtag', (event: IpcMainEvent, tag: LocalTag) => {
|
ipcMain.handle('remove-hashtag', async (_: IpcMainInvokeEvent, tag: LocalTag) => {
|
||||||
const hashtags = new Hashtags(hashtagsDB)
|
const hashtags = new Hashtags(hashtagsDB)
|
||||||
hashtags
|
await hashtags.removeTag(tag)
|
||||||
.removeTag(tag)
|
|
||||||
.then(() => {
|
|
||||||
event.sender.send('response-remove-hashtag')
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
event.sender.send('error-remove-hashtag', err)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
|
|
|
@ -29,20 +29,11 @@ const actions: ActionTree<ListState, RootState> = {
|
||||||
commit(MUTATION_TYPES.UPDATE_TAGS, tags)
|
commit(MUTATION_TYPES.UPDATE_TAGS, tags)
|
||||||
return tags
|
return tags
|
||||||
},
|
},
|
||||||
removeTag: ({ dispatch }, tag: LocalTag) => {
|
removeTag: async ({ dispatch }, tag: LocalTag) => {
|
||||||
return new Promise((resolve, reject) => {
|
await win.ipcRenderer.invoke('remove-hashtag', tag)
|
||||||
win.ipcRenderer.once('response-remove-hashtag', () => {
|
|
||||||
win.ipcRenderer.removeAllListeners('error-remove-hashtag')
|
|
||||||
dispatch('listTags')
|
dispatch('listTags')
|
||||||
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
||||||
resolve('deleted')
|
return 'deleted'
|
||||||
})
|
|
||||||
win.ipcRenderer.once('error-remove-hashtag', (_, err: Error) => {
|
|
||||||
win.ipcRenderer.removeAllListeners('response-remove-hashtag')
|
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
win.ipcRenderer.send('remove-hashtag', tag)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue