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

26 lines
661 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
'use strict';
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
2021-03-23 19:04:12 -07:00
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
const importAccount = (state, account) => {
return state.withMutations(state => {
if (account.has('pleroma')) {
const pleroPrefs = account.get('pleroma').delete('settings_store');
state.mergeIn(['pleroma'], pleroPrefs);
}
});
};
2020-03-27 13:59:38 -07:00
export default function meta(state = initialState, action) {
switch(action.type) {
case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS:
return importAccount(state, fromJS(action.me));
2020-03-27 13:59:38 -07:00
default:
return state;
}
};