Mastodon: fall back to account lookup API
This commit is contained in:
parent
7e7ca52cca
commit
6e889c7a4f
1 changed files with 8 additions and 8 deletions
|
@ -156,14 +156,7 @@ export function fetchAccountByUsername(username) {
|
||||||
const features = getFeatures(instance);
|
const features = getFeatures(instance);
|
||||||
const me = state.get('me');
|
const me = state.get('me');
|
||||||
|
|
||||||
if (!me && features.accountLookup) {
|
if (features.accountByUsername && (me || !features.accountLookup)) {
|
||||||
dispatch(accountLookup(username)).then(account => {
|
|
||||||
dispatch(fetchAccountSuccess(account));
|
|
||||||
}).catch(error => {
|
|
||||||
dispatch(fetchAccountFail(null, error));
|
|
||||||
dispatch(importErrorWhileFetchingAccountByUsername(username));
|
|
||||||
});
|
|
||||||
} else if (features.accountByUsername) {
|
|
||||||
api(getState).get(`/api/v1/accounts/${username}`).then(response => {
|
api(getState).get(`/api/v1/accounts/${username}`).then(response => {
|
||||||
dispatch(fetchRelationships([response.data.id]));
|
dispatch(fetchRelationships([response.data.id]));
|
||||||
dispatch(importFetchedAccount(response.data));
|
dispatch(importFetchedAccount(response.data));
|
||||||
|
@ -172,6 +165,13 @@ export function fetchAccountByUsername(username) {
|
||||||
dispatch(fetchAccountFail(null, error));
|
dispatch(fetchAccountFail(null, error));
|
||||||
dispatch(importErrorWhileFetchingAccountByUsername(username));
|
dispatch(importErrorWhileFetchingAccountByUsername(username));
|
||||||
});
|
});
|
||||||
|
} else if (features.accountLookup) {
|
||||||
|
dispatch(accountLookup(username)).then(account => {
|
||||||
|
dispatch(fetchAccountSuccess(account));
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch(fetchAccountFail(null, error));
|
||||||
|
dispatch(importErrorWhileFetchingAccountByUsername(username));
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch(accountSearch({
|
dispatch(accountSearch({
|
||||||
q: username,
|
q: username,
|
||||||
|
|
Loading…
Reference in a new issue