pleroma/app/soapbox/reducers/soapbox.js
crockwave cf260ec793 Handles virgin rendering, default soapbox object if soapbox.json missing, local state used only for UI changes, and retention of settings in both DB and store as soapbox object
Need to monitor for soapbox object dispatch events so that hitting Back causes re-render of timeline page
Need to explore refactoring update of soapbox object before being passed to API
2020-08-14 16:51:04 -05:00

41 lines
1.1 KiB
JavaScript

import {
SOAPBOX_CONFIG_REQUEST_SUCCESS,
SOAPBOX_CONFIG_REQUEST_FAIL,
SOAPBOX_POST_SUCCESS,
} from '../actions/soapbox';
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
const initialState = ImmutableMap();
const defaultState = ImmutableMap({
logo: '',
banner: '',
brandColor: '#0482d8', // Azure
customCss: ImmutableList([]),
promoPanel: ImmutableMap({
items: ImmutableList([]),
}),
extensions: ImmutableMap({
patron: false,
}),
defaultSettings: ImmutableMap({
autoPlayGif: false,
}),
copyright: '',
navlinks: ImmutableMap({
homeFooter: ImmutableList([]),
}),
});
export default function soapbox(state = initialState, action) {
switch(action.type) {
case SOAPBOX_CONFIG_REQUEST_SUCCESS:
return defaultState.merge(ImmutableMap(fromJS(action.soapboxConfig)));
case SOAPBOX_CONFIG_REQUEST_FAIL:
return defaultState;
case SOAPBOX_POST_SUCCESS:
return defaultState.merge(ImmutableMap(fromJS(action.soapboxConfig.configs[0].value[0].tuple[1])));
default:
return state;
}
};