2021-08-23 15:51:32 -07:00
|
|
|
/**
|
|
|
|
* Accounts Meta: private user data only the owner should see.
|
|
|
|
* @module soapbox/reducers/accounts_meta
|
|
|
|
*/
|
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-10-20 14:27:36 -07:00
|
|
|
import { VERIFY_CREDENTIALS_SUCCESS, AUTH_ACCOUNT_REMEMBER_SUCCESS } from 'soapbox/actions/auth';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me';
|
2021-08-23 15:51:32 -07:00
|
|
|
|
|
|
|
const initialState = ImmutableMap();
|
|
|
|
|
|
|
|
const importAccount = (state, account) => {
|
|
|
|
const accountId = account.get('id');
|
|
|
|
|
|
|
|
return state.set(accountId, ImmutableMap({
|
|
|
|
pleroma: account.get('pleroma', ImmutableMap()).delete('settings_store'),
|
|
|
|
source: account.get('source', ImmutableMap()),
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function accounts_meta(state = initialState, action) {
|
2022-05-11 10:40:34 -07:00
|
|
|
switch (action.type) {
|
2022-05-11 14:06:35 -07:00
|
|
|
case ME_FETCH_SUCCESS:
|
|
|
|
case ME_PATCH_SUCCESS:
|
|
|
|
return importAccount(state, fromJS(action.me));
|
|
|
|
case VERIFY_CREDENTIALS_SUCCESS:
|
|
|
|
case AUTH_ACCOUNT_REMEMBER_SUCCESS:
|
|
|
|
return importAccount(state, fromJS(action.account));
|
|
|
|
default:
|
|
|
|
return state;
|
2021-08-23 15:51:32 -07:00
|
|
|
}
|
|
|
|
}
|