diff --git a/src/main/index.ts b/src/main/index.ts index f0989cac..977768fb 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -465,7 +465,7 @@ ipcMain.on('start-all-user-streamings', (event: Event, accounts: Array { + async (update: Status) => { if (!event.sender.isDestroyed()) { event.sender.send(`update-start-all-user-streamings-${id}`, update) } @@ -473,6 +473,9 @@ ipcMain.on('start-all-user-streamings', (event: Event, accounts: Array { await hashtagCache.insertHashtag(tag.name) }) + // Cache account + // Ignore error for unique constratins. + await accountCache.insertAccount(id, update.account.acct).catch(err => console.info(err)) }, (notification: RemoteNotification) => { const preferences = new Preferences(preferencesDBPath) @@ -1021,9 +1024,8 @@ ipcMain.on('get-cache-accounts', async (event: Event, ownerID: string) => { ipcMain.on('insert-cache-accounts', (event: Event, obj: InsertAccountCache) => { const { ownerID, accts } = obj accts.map(async acct => { - await accountCache.insertAccount(ownerID, acct).catch(err => { - console.warn(err) - }) + // Ignore error for unique constratins. + await accountCache.insertAccount(ownerID, acct).catch(err => console.info(err)) }) event.sender.send('response-insert-cache-accounts') }) diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts index 4f95d4c0..121cfe5c 100644 --- a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts +++ b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts @@ -4,6 +4,7 @@ import Mastodon, { Account, Tag, Response, Results } from 'megalodon' import { Module, MutationTree, ActionTree, GetterTree } from 'vuex' import { RootState } from '@/store/index' import { LocalTag } from '~/src/types/localTag' +import { InsertAccountCache } from '~/src/types/insertAccountCache' type Suggest = { name: string @@ -113,6 +114,10 @@ const actions: ActionTree = { const res: Response = await client.get('/search', { q: word, resolve: false }) commit(MUTATION_TYPES.UPDATE_FILTERED_ACCOUNTS, res.data.accounts) if (res.data.accounts.length === 0) throw new Error('Empty') + ipcRenderer.send('insert-cache-accounts', { + ownerID: rootState.TimelineSpace.account._id!, + accts: res.data.accounts.map(a => a.acct) + } as InsertAccountCache) commit(MUTATION_TYPES.CHANGE_OPEN_SUGGEST, true) commit(MUTATION_TYPES.CHANGE_START_INDEX, start) commit(MUTATION_TYPES.CHANGE_MATCH_WORD, word)