refactor: Use invoke for ipc to insert cache accounts

This commit is contained in:
AkiraFukushima 2020-11-29 23:48:29 +09:00
parent 81c0781dae
commit ec3cb47c5d
2 changed files with 7 additions and 6 deletions

View File

@ -1043,12 +1043,13 @@ ipcMain.handle('get-cache-accounts', async (_: IpcMainInvokeEvent, ownerID: stri
return accounts
})
ipcMain.on('insert-cache-accounts', (event: IpcMainEvent, obj: InsertAccountCache) => {
ipcMain.handle('insert-cache-accounts', async (_: IpcMainInvokeEvent, obj: InsertAccountCache) => {
const { ownerID, accts } = obj
accts.map(async acct => {
await accountCache.insertAccount(ownerID, acct).catch(err => console.error(err))
})
event.sender.send('response-insert-cache-accounts')
Promise.all(
accts.map(async acct => {
await accountCache.insertAccount(ownerID, acct).catch(err => console.error(err))
})
)
})
// Application control

View File

@ -176,7 +176,7 @@ const actions: ActionTree<StatusState, RootState> = {
MUTATION_TYPES.APPEND_FILTERED_ACCOUNTS,
res.data.map(account => account.acct)
)
win.ipcRenderer.send('insert-cache-accounts', {
await win.ipcRenderer.invoke('insert-cache-accounts', {
ownerID: rootState.TimelineSpace.account._id!,
accts: res.data.map(a => a.acct)
} as InsertAccountCache)