Postpone setting the brand color until soapbox.json succeeds or fails

Fixes color flickering during load
merge-requests/31/merge
Alex Gleason 4 years ago
parent 8f566b70e6
commit 3e2b282cb8
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -48,7 +48,7 @@ const mapStateToProps = (state) => {
dyslexicFont: settings.get('dyslexicFont'),
demetricator: settings.get('demetricator'),
locale: settings.get('locale'),
themeCss: generateThemeCss(state.getIn(['soapbox', 'brandColor'], '#0482d8')), // Azure default
themeCss: generateThemeCss(state.getIn(['soapbox', 'brandColor'])),
themeMode: settings.get('themeMode'),
};
};

@ -1,12 +1,21 @@
import { SOAPBOX_CONFIG_REQUEST_SUCCESS } from '../actions/soapbox';
import {
SOAPBOX_CONFIG_REQUEST_SUCCESS,
SOAPBOX_CONFIG_REQUEST_FAIL,
} from '../actions/soapbox';
import { Map as ImmutableMap, fromJS } from 'immutable';
const initialState = ImmutableMap();
const defaultState = ImmutableMap({
brandColor: '#0482d8', // Azure
});
export default function soapbox(state = initialState, action) {
switch(action.type) {
case SOAPBOX_CONFIG_REQUEST_SUCCESS:
return ImmutableMap(fromJS(action.soapboxConfig));
return defaultState.merge(ImmutableMap(fromJS(action.soapboxConfig)));
case SOAPBOX_CONFIG_REQUEST_FAIL:
return defaultState;
default:
return state;
}

Loading…
Cancel
Save