Only support Pleroma for now

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2022-11-04 22:36:39 +01:00
parent 3448022965
commit 1ea4ae3a57
5 changed files with 6 additions and 41 deletions

View File

@ -1,6 +1,5 @@
import { createAsyncThunk } from '@reduxjs/toolkit';
import get from 'lodash/get';
import { gte } from 'semver';
import KVStore from 'soapbox/storage/kv_store';
import { RootState } from 'soapbox/store';
@ -38,12 +37,6 @@ const needsNodeinfo = (instance: Record<string, any>): boolean => {
return v.software === 'Pleroma' && !get(instance, ['pleroma', 'metadata']);
};
/** Mastodon exposes features availabiliy under /api/v2/instance since 4.0.0 */
const supportsInstanceV2 = (instance: Record<string, any>): boolean => {
const v = parseVersion(get(instance, 'version'));
return v.software === 'Mastodon' && gte(v.compatVersion, '4.0.0');
};
export const fetchInstance = createAsyncThunk<void, void, { state: RootState }>(
'instance/fetch',
async(_arg, { dispatch, getState, rejectWithValue }) => {
@ -52,9 +45,6 @@ export const fetchInstance = createAsyncThunk<void, void, { state: RootState }>(
if (needsNodeinfo(instance)) {
dispatch(fetchNodeinfo());
}
if (supportsInstanceV2(instance)) {
dispatch(fetchInstanceV2());
}
return instance;
} catch (e) {
return rejectWithValue(e);
@ -74,14 +64,6 @@ export const loadInstance = createAsyncThunk<void, void, { state: RootState }>(
},
);
export const fetchInstanceV2 = createAsyncThunk<void, void, { state: RootState }>(
'nodeinfo/fetch',
async(_arg, { getState }) => {
const { data: instance } = await api(getState).get('/api/v2/instance');
return instance;
},
);
export const fetchNodeinfo = createAsyncThunk<void, void, { state: RootState }>(
'nodeinfo/fetch',
async(_arg, { getState }) => await api(getState).get('/nodeinfo/2.1.json'),