refs #985 Save account cache when updated
This commit is contained in:
parent
e01156df08
commit
93a7ae5148
|
@ -465,7 +465,7 @@ ipcMain.on('start-all-user-streamings', (event: Event, accounts: Array<LocalAcco
|
|||
const url = await StreamingURL(acct)
|
||||
userStreamings[id] = new WebSocket(acct, url)
|
||||
userStreamings[id]!.startUserStreaming(
|
||||
(update: Status) => {
|
||||
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<LocalAcco
|
|||
update.tags.map(async tag => {
|
||||
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')
|
||||
})
|
||||
|
|
|
@ -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<StatusState, RootState> = {
|
|||
const res: Response<Results> = await client.get<Results>('/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)
|
||||
|
|
Loading…
Reference in New Issue