Merge branch 'mastodon-lookup-fix' into 'develop'
Mastodon: fall back to account lookup API See merge request soapbox-pub/soapbox-fe!1021
This commit is contained in:
commit
0799f19c83
|
@ -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,
|
||||||
|
|
|
@ -31,6 +31,14 @@ import configureStore from '../store/configureStore';
|
||||||
|
|
||||||
const validLocale = locale => Object.keys(messages).includes(locale);
|
const validLocale = locale => Object.keys(messages).includes(locale);
|
||||||
|
|
||||||
|
// Delay rendering until instance has loaded or failed (for feature detection)
|
||||||
|
const isInstanceLoaded = state => {
|
||||||
|
const v = state.getIn(['instance', 'version'], '0.0.0');
|
||||||
|
const fetchFailed = state.getIn(['meta', 'instance_fetch_failed'], false);
|
||||||
|
|
||||||
|
return v !== '0.0.0' || fetchFailed;
|
||||||
|
};
|
||||||
|
|
||||||
export const store = configureStore();
|
export const store = configureStore();
|
||||||
|
|
||||||
// Configure global functions for developers
|
// Configure global functions for developers
|
||||||
|
@ -60,6 +68,7 @@ const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
showIntroduction,
|
showIntroduction,
|
||||||
me,
|
me,
|
||||||
|
instanceLoaded: isInstanceLoaded(state),
|
||||||
reduceMotion: settings.get('reduceMotion'),
|
reduceMotion: settings.get('reduceMotion'),
|
||||||
underlineLinks: settings.get('underlineLinks'),
|
underlineLinks: settings.get('underlineLinks'),
|
||||||
systemFont: settings.get('systemFont'),
|
systemFont: settings.get('systemFont'),
|
||||||
|
@ -80,6 +89,7 @@ class SoapboxMount extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
showIntroduction: PropTypes.bool,
|
showIntroduction: PropTypes.bool,
|
||||||
me: SoapboxPropTypes.me,
|
me: SoapboxPropTypes.me,
|
||||||
|
instanceLoaded: PropTypes.bool,
|
||||||
reduceMotion: PropTypes.bool,
|
reduceMotion: PropTypes.bool,
|
||||||
underlineLinks: PropTypes.bool,
|
underlineLinks: PropTypes.bool,
|
||||||
systemFont: PropTypes.bool,
|
systemFont: PropTypes.bool,
|
||||||
|
@ -124,8 +134,9 @@ class SoapboxMount extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { me, themeCss, locale, customCss } = this.props;
|
const { me, instanceLoaded, themeCss, locale, customCss } = this.props;
|
||||||
if (me === null) return null;
|
if (me === null) return null;
|
||||||
|
if (!instanceLoaded) return null;
|
||||||
if (this.state.localeLoading) return null;
|
if (this.state.localeLoading) return null;
|
||||||
|
|
||||||
// Disabling introduction for launch
|
// Disabling introduction for launch
|
||||||
|
|
Loading…
Reference in New Issue