Merge branch 'takahe' into 'develop'
Support Takahē See merge request soapbox-pub/soapbox!2043
This commit is contained in:
commit
5c5bfccea6
5 changed files with 41 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
import { getFeatures } from 'soapbox/utils/features';
|
||||
|
||||
import api, { getLinks } from '../api';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
|
@ -18,10 +20,17 @@ const SCHEDULED_STATUS_CANCEL_FAIL = 'SCHEDULED_STATUS_CANCEL_FAIL';
|
|||
|
||||
const fetchScheduledStatuses = () =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
if (getState().status_lists.get('scheduled_statuses')?.isLoading) {
|
||||
const state = getState();
|
||||
|
||||
if (state.status_lists.get('scheduled_statuses')?.isLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
const instance = state.instance;
|
||||
const features = getFeatures(instance);
|
||||
|
||||
if (!features.scheduledStatuses) return;
|
||||
|
||||
dispatch(fetchScheduledStatusesRequest());
|
||||
|
||||
api(getState).get('/api/v1/scheduled_statuses').then(response => {
|
||||
|
|
|
@ -17,6 +17,8 @@ const fetchTrendingStatuses = () =>
|
|||
const instance = state.instance;
|
||||
const features = getFeatures(instance);
|
||||
|
||||
if (!features.trendingStatuses && !features.trendingTruths) return;
|
||||
|
||||
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
||||
return api(getState).get(features.trendingTruths ? '/api/v1/truth/trending/truths' : '/api/v1/trends/statuses').then(({ data: statuses }) => {
|
||||
dispatch(importFetchedStatuses(statuses));
|
||||
|
|
|
@ -52,7 +52,7 @@ const Settings = () => {
|
|||
const isMfaEnabled = mfa.getIn(['settings', 'totp']);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchMfa());
|
||||
if (features.security) dispatch(fetchMfa());
|
||||
}, [dispatch]);
|
||||
|
||||
if (!account) return null;
|
||||
|
|
|
@ -112,6 +112,17 @@ const fixAkkoma = (instance: ImmutableMap<string, any>) => {
|
|||
}
|
||||
};
|
||||
|
||||
/** Set Takahe version to a Pleroma-like string */
|
||||
const fixTakahe = (instance: ImmutableMap<string, any>) => {
|
||||
const version: string = instance.get('version', '');
|
||||
|
||||
if (version.startsWith('takahe/')) {
|
||||
return instance.set('version', `0.0.0 (compatible; Takahe ${version.slice(7)})`);
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
||||
// Normalize instance (Pleroma, Mastodon, etc.) to Mastodon's format
|
||||
export const normalizeInstance = (instance: Record<string, any>) => {
|
||||
return InstanceRecord(
|
||||
|
@ -131,6 +142,7 @@ export const normalizeInstance = (instance: Record<string, any>) => {
|
|||
|
||||
// Normalize version
|
||||
normalizeVersion(instance);
|
||||
fixTakahe(instance);
|
||||
fixAkkoma(instance);
|
||||
|
||||
// Merge defaults
|
||||
|
|
|
@ -64,6 +64,12 @@ export const GLITCH = 'glitch';
|
|||
*/
|
||||
export const AKKOMA = 'akkoma';
|
||||
|
||||
/**
|
||||
* Takahē, backend with support for serving multiple domains.
|
||||
* @see {@link https://jointakahe.org/}
|
||||
*/
|
||||
export const TAKAHE = 'Takahe';
|
||||
|
||||
/** Parse features for the given instance */
|
||||
const getInstanceFeatures = (instance: Instance) => {
|
||||
const v = parseVersion(instance.version);
|
||||
|
@ -288,6 +294,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === MASTODON && gte(v.compatVersion, '2.6.0'),
|
||||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
||||
v.software === PIXELFED,
|
||||
v.software === TAKAHE,
|
||||
]),
|
||||
|
||||
/**
|
||||
|
@ -299,6 +306,14 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
||||
]),
|
||||
|
||||
editProfile: any([
|
||||
v.software === MASTODON,
|
||||
v.software === MITRA,
|
||||
v.software === PIXELFED,
|
||||
v.software === PLEROMA,
|
||||
v.software === TRUTHSOCIAL,
|
||||
]),
|
||||
|
||||
editStatuses: any([
|
||||
v.software === MASTODON && gte(v.version, '3.5.0'),
|
||||
features.includes('editing'),
|
||||
|
@ -574,6 +589,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
publicTimeline: any([
|
||||
v.software === MASTODON,
|
||||
v.software === PLEROMA,
|
||||
v.software === TAKAHE,
|
||||
]),
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue