Merge branch 'takahe' into 'develop'
Support Takahē See merge request soapbox-pub/soapbox!2043
This commit is contained in:
commit
5c5bfccea6
|
@ -1,3 +1,5 @@
|
||||||
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
|
|
||||||
import api, { getLinks } from '../api';
|
import api, { getLinks } from '../api';
|
||||||
|
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError } from 'axios';
|
||||||
|
@ -18,10 +20,17 @@ const SCHEDULED_STATUS_CANCEL_FAIL = 'SCHEDULED_STATUS_CANCEL_FAIL';
|
||||||
|
|
||||||
const fetchScheduledStatuses = () =>
|
const fetchScheduledStatuses = () =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
if (getState().status_lists.get('scheduled_statuses')?.isLoading) {
|
const state = getState();
|
||||||
|
|
||||||
|
if (state.status_lists.get('scheduled_statuses')?.isLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const instance = state.instance;
|
||||||
|
const features = getFeatures(instance);
|
||||||
|
|
||||||
|
if (!features.scheduledStatuses) return;
|
||||||
|
|
||||||
dispatch(fetchScheduledStatusesRequest());
|
dispatch(fetchScheduledStatusesRequest());
|
||||||
|
|
||||||
api(getState).get('/api/v1/scheduled_statuses').then(response => {
|
api(getState).get('/api/v1/scheduled_statuses').then(response => {
|
||||||
|
|
|
@ -17,6 +17,8 @@ const fetchTrendingStatuses = () =>
|
||||||
const instance = state.instance;
|
const instance = state.instance;
|
||||||
const features = getFeatures(instance);
|
const features = getFeatures(instance);
|
||||||
|
|
||||||
|
if (!features.trendingStatuses && !features.trendingTruths) return;
|
||||||
|
|
||||||
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
dispatch({ type: TRENDING_STATUSES_FETCH_REQUEST });
|
||||||
return api(getState).get(features.trendingTruths ? '/api/v1/truth/trending/truths' : '/api/v1/trends/statuses').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));
|
||||||
|
|
|
@ -52,7 +52,7 @@ const Settings = () => {
|
||||||
const isMfaEnabled = mfa.getIn(['settings', 'totp']);
|
const isMfaEnabled = mfa.getIn(['settings', 'totp']);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(fetchMfa());
|
if (features.security) dispatch(fetchMfa());
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
if (!account) return null;
|
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
|
// Normalize instance (Pleroma, Mastodon, etc.) to Mastodon's format
|
||||||
export const normalizeInstance = (instance: Record<string, any>) => {
|
export const normalizeInstance = (instance: Record<string, any>) => {
|
||||||
return InstanceRecord(
|
return InstanceRecord(
|
||||||
|
@ -131,6 +142,7 @@ export const normalizeInstance = (instance: Record<string, any>) => {
|
||||||
|
|
||||||
// Normalize version
|
// Normalize version
|
||||||
normalizeVersion(instance);
|
normalizeVersion(instance);
|
||||||
|
fixTakahe(instance);
|
||||||
fixAkkoma(instance);
|
fixAkkoma(instance);
|
||||||
|
|
||||||
// Merge defaults
|
// Merge defaults
|
||||||
|
|
|
@ -64,6 +64,12 @@ export const GLITCH = 'glitch';
|
||||||
*/
|
*/
|
||||||
export const AKKOMA = 'akkoma';
|
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 */
|
/** Parse features for the given instance */
|
||||||
const getInstanceFeatures = (instance: Instance) => {
|
const getInstanceFeatures = (instance: Instance) => {
|
||||||
const v = parseVersion(instance.version);
|
const v = parseVersion(instance.version);
|
||||||
|
@ -288,6 +294,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
v.software === MASTODON && gte(v.compatVersion, '2.6.0'),
|
v.software === MASTODON && gte(v.compatVersion, '2.6.0'),
|
||||||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
||||||
v.software === PIXELFED,
|
v.software === PIXELFED,
|
||||||
|
v.software === TAKAHE,
|
||||||
]),
|
]),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -299,6 +306,14 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
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([
|
editStatuses: any([
|
||||||
v.software === MASTODON && gte(v.version, '3.5.0'),
|
v.software === MASTODON && gte(v.version, '3.5.0'),
|
||||||
features.includes('editing'),
|
features.includes('editing'),
|
||||||
|
@ -574,6 +589,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
publicTimeline: any([
|
publicTimeline: any([
|
||||||
v.software === MASTODON,
|
v.software === MASTODON,
|
||||||
v.software === PLEROMA,
|
v.software === PLEROMA,
|
||||||
|
v.software === TAKAHE,
|
||||||
]),
|
]),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue