Support trending statuses from Mastodon 3.5
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
6d4d96528c
commit
36c0fb5882
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
|
|
||||||
import api from '../api';
|
import api from '../api';
|
||||||
|
|
||||||
import { importFetchedStatuses } from './importer';
|
import { importFetchedStatuses } from './importer';
|
||||||
|
@ -8,8 +10,13 @@ export const TRENDING_STATUSES_FETCH_FAIL = 'TRENDING_STATUSES_FETCH_FAIL';
|
||||||
|
|
||||||
export function fetchTrendingStatuses() {
|
export function fetchTrendingStatuses() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
const state = getState();
|
||||||
|
|
||||||
|
const instance = state.get('instance');
|
||||||
|
const features = getFeatures(instance);
|
||||||
|
|
||||||
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
||||||
return api(getState).get('/api/v1/truth/trending/truths').then(({ data: statuses }) => {
|
return api(getState).get(features.trendingTruths ? '/api/v1/truth/trending/truths' : '/api/v1/trends/statuses').then(({ data: statuses }) => {
|
||||||
dispatch(importFetchedStatuses(statuses));
|
dispatch(importFetchedStatuses(statuses));
|
||||||
dispatch({ type: TRENDING_STATUSES_FETCH_SUCCESS, statuses });
|
dispatch({ type: TRENDING_STATUSES_FETCH_SUCCESS, statuses });
|
||||||
return statuses;
|
return statuses;
|
||||||
|
|
|
@ -123,6 +123,8 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
|
v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
|
||||||
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
v.software === PLEROMA && gte(v.version, '2.4.50'),
|
||||||
]),
|
]),
|
||||||
|
trendingTruths: v.software === TRUTHSOCIAL,
|
||||||
|
trendingStatuses: v.software === MASTODON && gte(v.compatVersion, '3.5.0'),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue