Preload /api/v1/instance

preload
Alex Gleason 2020-08-24 15:53:38 -05:00
rodzic 57340496bc
commit 20f64079e0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
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
const decodeUTF8Base64 = (data) => {

Wyświetl plik

@ -2,6 +2,7 @@ import {
INSTANCE_FETCH_SUCCESS,
NODEINFO_FETCH_SUCCESS,
} from '../actions/instance';
import { PRELOAD_IMPORT } from 'soapbox/actions/preload';
import { Map as ImmutableMap, fromJS } from 'immutable';
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) {
switch(action.type) {
case PRELOAD_IMPORT:
return preloadImport(state, action, '/api/v1/instance');
case INSTANCE_FETCH_SUCCESS:
return initialState.mergeDeep(fromJS(action.instance));
case NODEINFO_FETCH_SUCCESS: