logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

height_cache.js (621B)


  1. import { Map as ImmutableMap } from 'immutable';
  2. import { HEIGHT_CACHE_SET, HEIGHT_CACHE_CLEAR } from '../actions/height_cache';
  3. const initialState = ImmutableMap();
  4. const setHeight = (state, key, id, height) => {
  5. return state.update(key, ImmutableMap(), map => map.set(id, height));
  6. };
  7. const clearHeights = () => {
  8. return ImmutableMap();
  9. };
  10. export default function statuses(state = initialState, action) {
  11. switch(action.type) {
  12. case HEIGHT_CACHE_SET:
  13. return setHeight(state, action.key, action.id, action.height);
  14. case HEIGHT_CACHE_CLEAR:
  15. return clearHeights();
  16. default:
  17. return state;
  18. }
  19. };