The code powering m.abunchtell.com https://m.abunchtell.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

66 rindas
2.0 KiB

  1. import {
  2. REBLOG_REQUEST,
  3. REBLOG_FAIL,
  4. FAVOURITE_REQUEST,
  5. FAVOURITE_FAIL,
  6. } from '../actions/interactions';
  7. import {
  8. STATUS_MUTE_SUCCESS,
  9. STATUS_UNMUTE_SUCCESS,
  10. STATUS_REVEAL,
  11. STATUS_HIDE,
  12. } from '../actions/statuses';
  13. import {
  14. TIMELINE_DELETE,
  15. } from '../actions/timelines';
  16. import { STATUS_IMPORT, STATUSES_IMPORT } from '../actions/importer';
  17. import { Map as ImmutableMap, fromJS } from 'immutable';
  18. const importStatus = (state, status) => state.set(status.id, fromJS(status));
  19. const importStatuses = (state, statuses) =>
  20. state.withMutations(mutable => statuses.forEach(status => importStatus(mutable, status)));
  21. const deleteStatus = (state, id, references) => {
  22. references.forEach(ref => {
  23. state = deleteStatus(state, ref[0], []);
  24. });
  25. return state.delete(id);
  26. };
  27. const initialState = ImmutableMap();
  28. export default function statuses(state = initialState, action) {
  29. switch(action.type) {
  30. case STATUS_IMPORT:
  31. return importStatus(state, action.status);
  32. case STATUSES_IMPORT:
  33. return importStatuses(state, action.statuses);
  34. case FAVOURITE_REQUEST:
  35. return state.setIn([action.status.get('id'), 'favourited'], true);
  36. case FAVOURITE_FAIL:
  37. return state.setIn([action.status.get('id'), 'favourited'], false);
  38. case REBLOG_REQUEST:
  39. return state.setIn([action.status.get('id'), 'reblogged'], true);
  40. case REBLOG_FAIL:
  41. return state.setIn([action.status.get('id'), 'reblogged'], false);
  42. case STATUS_MUTE_SUCCESS:
  43. return state.setIn([action.id, 'muted'], true);
  44. case STATUS_UNMUTE_SUCCESS:
  45. return state.setIn([action.id, 'muted'], false);
  46. case STATUS_REVEAL:
  47. return state.withMutations(map => {
  48. action.ids.forEach(id => map.setIn([id, 'hidden'], false));
  49. });
  50. case STATUS_HIDE:
  51. return state.withMutations(map => {
  52. action.ids.forEach(id => map.setIn([id, 'hidden'], true));
  53. });
  54. case TIMELINE_DELETE:
  55. return deleteStatus(state, action.id, action.references);
  56. default:
  57. return state;
  58. }
  59. };