Only support Pleroma for now
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user