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 return accounts
}) })
ipcMain.on('insert-cache-accounts', (event: IpcMainEvent, obj: InsertAccountCache) => { ipcMain.handle('insert-cache-accounts', async (_: IpcMainInvokeEvent, obj: InsertAccountCache) => {
const { ownerID, accts } = obj const { ownerID, accts } = obj
accts.map(async acct => { Promise.all(
await accountCache.insertAccount(ownerID, acct).catch(err => console.error(err)) accts.map(async acct => {
}) await accountCache.insertAccount(ownerID, acct).catch(err => console.error(err))
event.sender.send('response-insert-cache-accounts') })
)
}) })
// Application control // Application control

View File

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