From 81e1e2d6add157115eb909de3b09133a3a03057d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 27 Dec 2022 21:42:17 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Support=20Takah=C4=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/scheduled-statuses.ts | 11 ++++++++++- app/soapbox/actions/trending-statuses.ts | 2 ++ app/soapbox/features/settings/index.tsx | 2 +- app/soapbox/normalizers/instance.ts | 12 ++++++++++++ app/soapbox/utils/features.ts | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/app/soapbox/actions/scheduled-statuses.ts b/app/soapbox/actions/scheduled-statuses.ts index ddc5501055..33e7637017 100644 --- a/app/soapbox/actions/scheduled-statuses.ts +++ b/app/soapbox/actions/scheduled-statuses.ts @@ -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 => { diff --git a/app/soapbox/actions/trending-statuses.ts b/app/soapbox/actions/trending-statuses.ts index 435fcf6df9..7ccab27ab3 100644 --- a/app/soapbox/actions/trending-statuses.ts +++ b/app/soapbox/actions/trending-statuses.ts @@ -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)); diff --git a/app/soapbox/features/settings/index.tsx b/app/soapbox/features/settings/index.tsx index c0a7a30563..06b8bf8a26 100644 --- a/app/soapbox/features/settings/index.tsx +++ b/app/soapbox/features/settings/index.tsx @@ -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; diff --git a/app/soapbox/normalizers/instance.ts b/app/soapbox/normalizers/instance.ts index e7933b080f..8a13a89b87 100644 --- a/app/soapbox/normalizers/instance.ts +++ b/app/soapbox/normalizers/instance.ts @@ -101,6 +101,17 @@ const normalizeVersion = (instance: ImmutableMap) => { }); }; +/** Rename Akkoma to Pleroma+akkoma */ +const fixTakahe = (instance: ImmutableMap) => { + 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; + } +}; + /** Rename Akkoma to Pleroma+akkoma */ const fixAkkoma = (instance: ImmutableMap) => { const version: string = instance.get('version', ''); @@ -131,6 +142,7 @@ export const normalizeInstance = (instance: Record) => { // Normalize version normalizeVersion(instance); + fixTakahe(instance); fixAkkoma(instance); // Merge defaults diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index deb53b0cb1..cd5addccea 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -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, ]), /** From 3f430ee5d58c1bef71a96a828bbcedd9bff77454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 27 Dec 2022 23:56:33 +0100 Subject: [PATCH 2/2] use capitalized name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/normalizers/instance.ts | 22 +++++++++++----------- app/soapbox/utils/features.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/soapbox/normalizers/instance.ts b/app/soapbox/normalizers/instance.ts index 8a13a89b87..48214b0912 100644 --- a/app/soapbox/normalizers/instance.ts +++ b/app/soapbox/normalizers/instance.ts @@ -101,17 +101,6 @@ const normalizeVersion = (instance: ImmutableMap) => { }); }; -/** Rename Akkoma to Pleroma+akkoma */ -const fixTakahe = (instance: ImmutableMap) => { - 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; - } -}; - /** Rename Akkoma to Pleroma+akkoma */ const fixAkkoma = (instance: ImmutableMap) => { const version: string = instance.get('version', ''); @@ -123,6 +112,17 @@ const fixAkkoma = (instance: ImmutableMap) => { } }; +/** Set Takahe version to a Pleroma-like string */ +const fixTakahe = (instance: ImmutableMap) => { + 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) => { return InstanceRecord( diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index cd5addccea..42947f340f 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -68,7 +68,7 @@ export const AKKOMA = 'akkoma'; * Takahē, backend with support for serving multiple domains. * @see {@link https://jointakahe.org/} */ -export const TAKAHE = 'takahe'; +export const TAKAHE = 'Takahe'; /** Parse features for the given instance */ const getInstanceFeatures = (instance: Instance) => {