]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/reducers/statuses.js
9 } from '../actions/interactions';
12 STATUS_UNMUTE_SUCCESS
,
16 } from '../actions/statuses';
17 import { TIMELINE_DELETE
} from '../actions/timelines';
18 import { STATUS_IMPORT
, STATUSES_IMPORT
} from '../actions/importer';
19 import { Map as ImmutableMap
, fromJS
} from 'immutable';
21 const importStatus
= (state
, status
) => state
.set(status
.id
, fromJS(status
));
23 const importStatuses
= (state
, statuses
) =>
24 state
.withMutations(mutable
=> statuses
.forEach(status
=> importStatus(mutable
, status
)));
26 const deleteStatus
= (state
, id
, references
) => {
27 references
.forEach(ref
=> {
28 state
= deleteStatus(state
, ref
[0], []);
31 return state
.delete(id
);
34 const initialState
= ImmutableMap();
36 export default function statuses(state
= initialState
, action
) {
39 return importStatus(state
, action
.status
);
41 return importStatuses(state
, action
.statuses
);
42 case FAVOURITE_REQUEST:
43 return state
.setIn([action
.status
.get('id'), 'favourited'], true);
44 case UNFAVOURITE_SUCCESS:
45 const favouritesCount
= action
.status
.get('favourites_count');
46 return state
.setIn([action
.status
.get('id'), 'favourites_count'], favouritesCount
- 1);
48 return state
.get(action
.status
.get('id')) === undefined ? state : state
.setIn([action
.status
.get('id'), 'favourited'], false);
49 case BOOKMARK_REQUEST:
50 return state
.get(action
.status
.get('id')) === undefined ? state : state
.setIn([action
.status
.get('id'), 'bookmarked'], true);
52 return state
.get(action
.status
.get('id')) === undefined ? state : state
.setIn([action
.status
.get('id'), 'bookmarked'], false);
54 return state
.setIn([action
.status
.get('id'), 'reblogged'], true);
56 return state
.get(action
.status
.get('id')) === undefined ? state : state
.setIn([action
.status
.get('id'), 'reblogged'], false);
57 case STATUS_MUTE_SUCCESS:
58 return state
.setIn([action
.id
, 'muted'], true);
59 case STATUS_UNMUTE_SUCCESS:
60 return state
.setIn([action
.id
, 'muted'], false);
62 return state
.withMutations(map
=> {
63 action
.ids
.forEach(id
=> {
64 if (!(state
.get(id
) === undefined)) {
65 map
.setIn([id
, 'hidden'], false);
70 return state
.withMutations(map
=> {
71 action
.ids
.forEach(id
=> {
72 if (!(state
.get(id
) === undefined)) {
73 map
.setIn([id
, 'hidden'], true);
78 return state
.setIn([action
.id
, 'collapsed'], action
.isCollapsed
);
80 return deleteStatus(state
, action
.id
, action
.references
);
This page took 0.108558 seconds and 5 git commands to generate.