Preload /api/v1/instance
This commit is contained in:
parent
57340496bc
commit
20f64079e0
2 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { mapValues } from 'lodash';
|
import { mapValues } from 'lodash';
|
||||||
|
|
||||||
const PRELOAD_IMPORT = 'PRELOAD_IMPORT';
|
export const PRELOAD_IMPORT = 'PRELOAD_IMPORT';
|
||||||
|
|
||||||
// https://git.pleroma.social/pleroma/pleroma-fe/-/merge_requests/1176/diffs
|
// https://git.pleroma.social/pleroma/pleroma-fe/-/merge_requests/1176/diffs
|
||||||
const decodeUTF8Base64 = (data) => {
|
const decodeUTF8Base64 = (data) => {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {
|
||||||
INSTANCE_FETCH_SUCCESS,
|
INSTANCE_FETCH_SUCCESS,
|
||||||
NODEINFO_FETCH_SUCCESS,
|
NODEINFO_FETCH_SUCCESS,
|
||||||
} from '../actions/instance';
|
} from '../actions/instance';
|
||||||
|
import { PRELOAD_IMPORT } from 'soapbox/actions/preload';
|
||||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const nodeinfoToInstance = nodeinfo => {
|
const nodeinfoToInstance = nodeinfo => {
|
||||||
|
@ -31,8 +32,15 @@ const initialState = ImmutableMap({
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const preloadImport = (state, action, path) => {
|
||||||
|
const data = action.data[path];
|
||||||
|
return data ? initialState.mergeDeep(fromJS(data)) : state;
|
||||||
|
};
|
||||||
|
|
||||||
export default function instance(state = initialState, action) {
|
export default function instance(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
case PRELOAD_IMPORT:
|
||||||
|
return preloadImport(state, action, '/api/v1/instance');
|
||||||
case INSTANCE_FETCH_SUCCESS:
|
case INSTANCE_FETCH_SUCCESS:
|
||||||
return initialState.mergeDeep(fromJS(action.instance));
|
return initialState.mergeDeep(fromJS(action.instance));
|
||||||
case NODEINFO_FETCH_SUCCESS:
|
case NODEINFO_FETCH_SUCCESS:
|
||||||
|
|
Loading…
Reference in a new issue