refactor: Use invoke for ipc to insert cache hashtags

This commit is contained in:
AkiraFukushima 2020-11-29 23:43:24 +09:00
parent d2ca00354b
commit 9308a27f64
2 changed files with 7 additions and 6 deletions

View File

@ -1030,11 +1030,12 @@ ipcMain.handle('get-cache-hashtags', async (_: IpcMainInvokeEvent) => {
return tags return tags
}) })
ipcMain.on('insert-cache-hashtags', (event: IpcMainEvent, tags: Array<string>) => { ipcMain.handle('insert-cache-hashtags', async (_: IpcMainInvokeEvent, tags: Array<string>) => {
await Promise.all(
tags.map(async name => { tags.map(async name => {
await hashtagCache.insertHashtag(name).catch(err => console.error(err)) await hashtagCache.insertHashtag(name).catch(err => console.error(err))
}) })
event.sender.send('response-insert-cache-hashtags') )
}) })
ipcMain.on('get-cache-accounts', async (event: IpcMainEvent, ownerID: string) => { ipcMain.on('get-cache-accounts', async (event: IpcMainEvent, ownerID: string) => {

View File

@ -223,7 +223,7 @@ const actions: ActionTree<StatusState, RootState> = {
MUTATION_TYPES.APPEND_FILTERED_HASHTAGS, MUTATION_TYPES.APPEND_FILTERED_HASHTAGS,
res.data.hashtags.map(tag => tag.name) res.data.hashtags.map(tag => tag.name)
) )
win.ipcRenderer.send( await win.ipcRenderer.invoke(
'insert-cache-hashtags', 'insert-cache-hashtags',
res.data.hashtags.map(tag => tag.name) res.data.hashtags.map(tag => tag.name)
) )