committed by
Thibaut Girka
parent
0d19fcc2fb
commit
8d70a8a19b
@ -29,6 +29,7 @@ import listEditor from './list_editor';
|
||||
import listAdder from './list_adder';
|
||||
import filters from './filters';
|
||||
import pinnedAccountsEditor from './pinned_accounts_editor';
|
||||
import polls from './polls';
|
||||
|
||||
const reducers = {
|
||||
dropdown_menu,
|
||||
@ -61,6 +62,7 @@ const reducers = {
|
||||
listAdder,
|
||||
filters,
|
||||
pinnedAccountsEditor,
|
||||
polls,
|
||||
};
|
||||
|
||||
export default combineReducers(reducers);
|
||||
|
19
app/javascript/flavours/glitch/reducers/polls.js
Normal file
19
app/javascript/flavours/glitch/reducers/polls.js
Normal file
@ -0,0 +1,19 @@
|
||||
import { POLL_VOTE_SUCCESS, POLL_FETCH_SUCCESS } from 'mastodon/actions/polls';
|
||||
import { POLLS_IMPORT } from 'mastodon/actions/importer';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
const importPolls = (state, polls) => state.withMutations(map => polls.forEach(poll => map.set(poll.id, fromJS(poll))));
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
export default function polls(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case POLLS_IMPORT:
|
||||
return importPolls(state, action.polls);
|
||||
case POLL_VOTE_SUCCESS:
|
||||
case POLL_FETCH_SUCCESS:
|
||||
return importPolls(state, [action.poll]);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user