bigbuffet-rw/app/soapbox/reducers/meta.js

25 lines
686 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
'use strict';
import { STORE_HYDRATE } from '../actions/store';
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
import { Map as ImmutableMap, fromJS } from 'immutable';
2020-03-27 13:59:38 -07:00
const initialState = ImmutableMap();
2020-03-27 13:59:38 -07:00
export default function meta(state = initialState, action) {
switch(action.type) {
case STORE_HYDRATE:
return state.merge(action.state.get('meta'));
case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS:
const me = fromJS(action.me);
2020-04-23 09:42:56 -07:00
if (me.has('pleroma')) {
const pleroPrefs = me.get('pleroma').delete('settings_store');
return state.mergeIn(['pleroma'], pleroPrefs);
}
return state;
2020-03-27 13:59:38 -07:00
default:
return state;
}
};