Add polls

Port front-end parts of 230a012f00 to glitch-soc
This commit is contained in:
Eugen Rochko
2019-03-03 22:18:23 +01:00
committed by Thibaut Girka
parent 0d19fcc2fb
commit 8d70a8a19b
13 changed files with 355 additions and 8 deletions

View File

@ -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);

View 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;
}
}