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
|
||||
})
|
||||
|
||||
ipcMain.on('remove-hashtag', (event: IpcMainEvent, tag: LocalTag) => {
|
||||
ipcMain.handle('remove-hashtag', async (_: IpcMainInvokeEvent, tag: LocalTag) => {
|
||||
const hashtags = new Hashtags(hashtagsDB)
|
||||
hashtags
|
||||
.removeTag(tag)
|
||||
.then(() => {
|
||||
event.sender.send('response-remove-hashtag')
|
||||
})
|
||||
.catch(err => {
|
||||
event.sender.send('error-remove-hashtag', err)
|
||||
})
|
||||
await hashtags.removeTag(tag)
|
||||
})
|
||||
|
||||
// Fonts
|
||||
|
|
|
@ -29,20 +29,11 @@ const actions: ActionTree<ListState, RootState> = {
|
|||
commit(MUTATION_TYPES.UPDATE_TAGS, tags)
|
||||
return tags
|
||||
},
|
||||
removeTag: ({ dispatch }, tag: LocalTag) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
win.ipcRenderer.once('response-remove-hashtag', () => {
|
||||
win.ipcRenderer.removeAllListeners('error-remove-hashtag')
|
||||
dispatch('listTags')
|
||||
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
||||
resolve('deleted')
|
||||
})
|
||||
win.ipcRenderer.once('error-remove-hashtag', (_, err: Error) => {
|
||||
win.ipcRenderer.removeAllListeners('response-remove-hashtag')
|
||||
reject(err)
|
||||
})
|
||||
win.ipcRenderer.send('remove-hashtag', tag)
|
||||
})
|
||||
removeTag: async ({ dispatch }, tag: LocalTag) => {
|
||||
await win.ipcRenderer.invoke('remove-hashtag', tag)
|
||||
dispatch('listTags')
|
||||
dispatch('TimelineSpace/SideMenu/listTags', {}, { root: true })
|
||||
return 'deleted'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue