Merge branch 'preload-fe-config' into 'develop'
Preload frontend config See merge request soapbox-pub/soapbox-fe!366
This commit is contained in:
commit
2104739f2c
|
@ -3,6 +3,7 @@ import {
|
||||||
SOAPBOX_CONFIG_REQUEST_SUCCESS,
|
SOAPBOX_CONFIG_REQUEST_SUCCESS,
|
||||||
SOAPBOX_CONFIG_REQUEST_FAIL,
|
SOAPBOX_CONFIG_REQUEST_FAIL,
|
||||||
} from '../actions/soapbox';
|
} from '../actions/soapbox';
|
||||||
|
import { PRELOAD_IMPORT } from 'soapbox/actions/preload';
|
||||||
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
|
||||||
import { ConfigDB } from 'soapbox/utils/config_db';
|
import { ConfigDB } from 'soapbox/utils/config_db';
|
||||||
|
|
||||||
|
@ -25,8 +26,22 @@ const updateFromAdmin = (state, config) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const preloadImport = (state, action) => {
|
||||||
|
const path = '/api/pleroma/frontend_configurations';
|
||||||
|
const feData = action.data[path];
|
||||||
|
|
||||||
|
if (feData) {
|
||||||
|
const soapbox = feData.soapbox_fe;
|
||||||
|
return soapbox ? fallbackState.mergeDeep(fromJS(soapbox)) : fallbackState;
|
||||||
|
} else {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default function soapbox(state = initialState, action) {
|
export default function soapbox(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
case PRELOAD_IMPORT:
|
||||||
|
return preloadImport(state, action);
|
||||||
case SOAPBOX_CONFIG_REQUEST_SUCCESS:
|
case SOAPBOX_CONFIG_REQUEST_SUCCESS:
|
||||||
return fromJS(action.soapboxConfig);
|
return fromJS(action.soapboxConfig);
|
||||||
case SOAPBOX_CONFIG_REQUEST_FAIL:
|
case SOAPBOX_CONFIG_REQUEST_FAIL:
|
||||||
|
|
Loading…
Reference in New Issue