]> cat aescling's git repositories - mastodon.git/blob - app/javascript/themes/glitch/reducers/height_cache.js
Forking glitch theme
[mastodon.git] / app / javascript / themes / glitch / reducers / height_cache.js
1 import { Map as ImmutableMap } from 'immutable';
2 import { HEIGHT_CACHE_SET, HEIGHT_CACHE_CLEAR } from 'themes/glitch/actions/height_cache';
3
4 const initialState = ImmutableMap();
5
6 const setHeight = (state, key, id, height) => {
7 return state.update(key, ImmutableMap(), map => map.set(id, height));
8 };
9
10 const clearHeights = () => {
11 return ImmutableMap();
12 };
13
14 export default function statuses(state = initialState, action) {
15 switch(action.type) {
16 case HEIGHT_CACHE_SET:
17 return setHeight(state, action.key, action.id, action.height);
18 case HEIGHT_CACHE_CLEAR:
19 return clearHeights();
20 default:
21 return state;
22 }
23 };
This page took 0.074309 seconds and 4 git commands to generate.