Add polls (#10111)
* Add polls Fix #1629 * Add tests * Fixes * Change API for creating polls * Use name instead of content for votes * Remove poll validation for remote polls * Add polls to public pages * When updating the poll, update options just in case they were changed * Fix public pages showing both poll and other media
This commit is contained in:
parent
99dc212ae5
commit
230a012f00
47 changed files with 1038 additions and 19 deletions
19
app/javascript/mastodon/reducers/polls.js
Normal file
19
app/javascript/mastodon/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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue