mastodon/app/javascript/flavours/glitch/reducers/meta.js
fusagiko / takayamaki 3d9e35375c [Glitch] Rewrite actions/app.ts and reducers/missed_updates.ts with createAction
Port 0999cb4601 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2023-05-08 22:15:00 +02:00

25 lines
813 B
JavaScript

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