1
0
puyopuyotetr.is/app/javascript/flavours/glitch/reducers/meta.js
Renaud Chaput 3e9298370d [Glitch] Remove the access token from Redux & context
Port 2c5ab8f647 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2024-05-22 21:14:54 +02:00

24 lines
782 B
JavaScript

import { Map as ImmutableMap } from 'immutable';
import { changeLayout } from 'flavours/glitch/actions/app';
import { STORE_HYDRATE } from 'flavours/glitch/actions/store';
import { layoutFromWindow } from 'flavours/glitch/is_mobile';
const initialState = ImmutableMap({
streaming_api_base_url: null,
layout: layoutFromWindow(),
permissions: '0',
});
export default function meta(state = initialState, action) {
switch(action.type) {
case STORE_HYDRATE:
// we do not want `access_token` to be stored in the state
return state.merge(action.state.get('meta')).delete('access_token').set('permissions', action.state.getIn(['role', 'permissions']));
case changeLayout.type:
return state.set('layout', action.payload.layout);
default:
return state;
}
}