Skip to content

Commit

Permalink
Make delete & redraft work with polls
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Mar 6, 2019
1 parent 6160f5c commit d948f04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/javascript/mastodon/actions/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ export function redraft(status) {

export function deleteStatus(id, router, withRedraft = false) {
return (dispatch, getState) => {
const status = getState().getIn(['statuses', id]);
let status = getState().getIn(['statuses', id]);

if (status.get('poll')) {
status = status.set('poll', getState().getIn(['polls', status.get('poll')]));
}

dispatch(deleteStatusRequest(id));

Expand Down
8 changes: 8 additions & 0 deletions app/javascript/mastodon/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ export default function compose(state = initialState, action) {
map.set('spoiler', false);
map.set('spoiler_text', '');
}

if (action.status.get('poll')) {
map.set('poll', ImmutableMap({
options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
multiple: action.status.getIn(['poll', 'multiple']),
expires_in: 24 * 3600,
}));
}
});
case COMPOSE_POLL_ADD:
return state.set('poll', initialPoll);
Expand Down

0 comments on commit d948f04

Please sign in to comment.