From 58b88cbcff7f01682eb9738b9de1020a129f875f Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 11 Aug 2019 11:53:35 +0900
Subject: [PATCH] refs #991 Use acccounts/search API for suggest accounts
---
.../store/TimelineSpace/Modals/NewToot/Status.ts | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
index 2a4905c3..3c8c5a66 100644
--- a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
+++ b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
@@ -1,6 +1,6 @@
import { ipcRenderer } from 'electron'
import emojilib from 'emojilib'
-import Mastodon, { Response, Results } from 'megalodon'
+import Mastodon, { Account, Response, Results } from 'megalodon'
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
import { RootState } from '@/store/index'
import { LocalTag } from '~/src/types/localTag'
@@ -154,19 +154,19 @@ const actions: ActionTree = {
})
}
const searchAPI = async () => {
- const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v2')
- const res: Response = await client.get('/search', { q: word, resolve: false })
- if (res.data.accounts.length === 0) throw new Error('Empty')
- commit(MUTATION_TYPES.APPEND_FILTERED_ACCOUNTS, res.data.accounts.map(account => account.acct))
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
+ const res: Response> = await client.get>('/accounts/search', { q: word, resolve: false })
+ if (res.data.length === 0) throw new Error('Empty')
+ commit(MUTATION_TYPES.APPEND_FILTERED_ACCOUNTS, res.data.map(account => account.acct))
ipcRenderer.send('insert-cache-accounts', {
ownerID: rootState.TimelineSpace.account._id!,
- accts: res.data.accounts.map(a => a.acct)
+ accts: res.data.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)
commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_ACCOUNTS)
- return res.data.accounts
+ return res.data
}
await Promise.all([searchCache(), searchAPI()])
},