1
0
mirror of https://github.com/tooot-app/app synced 2024-12-24 00:21:35 +01:00

Use account lookup instead of search

May increase success rate
This commit is contained in:
xmflsct 2022-12-18 01:29:33 +01:00
parent fea2e82bdd
commit b1f00ce99b

View File

@ -45,21 +45,17 @@ const queryFunction = async ({
throw new Error() throw new Error()
} }
const resSearch = await apiGeneral<{ accounts: Mastodon.Account[] }>({ const resLookup = await apiGeneral<Mastodon.Account>({
method: 'get', method: 'get',
domain, domain,
url: 'api/v2/search', url: 'api/v1/accounts/lookup',
params: { params: { acct: page.account.acct }
q: `@${page.account.acct}`,
type: 'accounts',
limit: '1'
}
}) })
if (resSearch?.body?.accounts?.length === 1) { if (resLookup?.body) {
res = await apiGeneral<Mastodon.Account[]>({ res = await apiGeneral<Mastodon.Account[]>({
method: 'get', method: 'get',
domain, domain,
url: `api/v1/${page.reference}/${resSearch.body.accounts[0].id}/${page.type}`, url: `api/v1/${page.reference}/${resLookup.body.id}/${page.type}`,
params params
}) })
return { ...res, remoteData: true } return { ...res, remoteData: true }