forked from cybrespace/mastodon
Fix poll options not rendering text after vote/refresh (#10189)
* Fix poll options not rendering text after vote/refresh * Fix poll options not showing up on public pages * Fix code style issue
This commit is contained in:
parent
57643557b6
commit
fd128b9c7a
|
@ -82,3 +82,9 @@ export function importFetchedStatuses(statuses) {
|
||||||
dispatch(importStatuses(normalStatuses));
|
dispatch(importStatuses(normalStatuses));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function importFetchedPoll(poll) {
|
||||||
|
return dispatch => {
|
||||||
|
dispatch(importPolls([normalizePoll(poll)]));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import api from '../api';
|
import api from '../api';
|
||||||
|
import { importFetchedPoll } from './importer';
|
||||||
|
|
||||||
export const POLL_VOTE_REQUEST = 'POLL_VOTE_REQUEST';
|
export const POLL_VOTE_REQUEST = 'POLL_VOTE_REQUEST';
|
||||||
export const POLL_VOTE_SUCCESS = 'POLL_VOTE_SUCCESS';
|
export const POLL_VOTE_SUCCESS = 'POLL_VOTE_SUCCESS';
|
||||||
|
@ -12,7 +13,10 @@ export const vote = (pollId, choices) => (dispatch, getState) => {
|
||||||
dispatch(voteRequest());
|
dispatch(voteRequest());
|
||||||
|
|
||||||
api(getState).post(`/api/v1/polls/${pollId}/votes`, { choices })
|
api(getState).post(`/api/v1/polls/${pollId}/votes`, { choices })
|
||||||
.then(({ data }) => dispatch(voteSuccess(data)))
|
.then(({ data }) => {
|
||||||
|
dispatch(importFetchedPoll(data));
|
||||||
|
dispatch(voteSuccess(data));
|
||||||
|
})
|
||||||
.catch(err => dispatch(voteFail(err)));
|
.catch(err => dispatch(voteFail(err)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +24,10 @@ export const fetchPoll = pollId => (dispatch, getState) => {
|
||||||
dispatch(fetchPollRequest());
|
dispatch(fetchPollRequest());
|
||||||
|
|
||||||
api(getState).get(`/api/v1/polls/${pollId}`)
|
api(getState).get(`/api/v1/polls/${pollId}`)
|
||||||
.then(({ data }) => dispatch(fetchPollSuccess(data)))
|
.then(({ data }) => {
|
||||||
|
dispatch(importFetchedPoll(data));
|
||||||
|
dispatch(fetchPollSuccess(data));
|
||||||
|
})
|
||||||
.catch(err => dispatch(fetchPollFail(err)));
|
.catch(err => dispatch(fetchPollFail(err)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ import classNames from 'classnames';
|
||||||
import { vote, fetchPoll } from 'mastodon/actions/polls';
|
import { vote, fetchPoll } from 'mastodon/actions/polls';
|
||||||
import Motion from 'mastodon/features/ui/util/optional_motion';
|
import Motion from 'mastodon/features/ui/util/optional_motion';
|
||||||
import spring from 'react-motion/lib/spring';
|
import spring from 'react-motion/lib/spring';
|
||||||
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
|
import emojify from 'mastodon/features/emoji/emoji';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
moments: { id: 'time_remaining.moments', defaultMessage: 'Moments remaining' },
|
moments: { id: 'time_remaining.moments', defaultMessage: 'Moments remaining' },
|
||||||
|
@ -120,7 +122,7 @@ class Poll extends ImmutablePureComponent {
|
||||||
{!showResults && <span className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} />}
|
{!showResults && <span className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} />}
|
||||||
{showResults && <span className='poll__number'>{Math.round(percent)}%</span>}
|
{showResults && <span className='poll__number'>{Math.round(percent)}%</span>}
|
||||||
|
|
||||||
<span dangerouslySetInnerHTML={{ __html: option.get('title_emojified') }} />
|
<span dangerouslySetInnerHTML={{ __html: option.get('title_emojified', emojify(escapeTextContentForBrowser(option.get('title')))) }} />
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { POLL_VOTE_SUCCESS, POLL_FETCH_SUCCESS } from 'mastodon/actions/polls';
|
|
||||||
import { POLLS_IMPORT } from 'mastodon/actions/importer';
|
import { POLLS_IMPORT } from 'mastodon/actions/importer';
|
||||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
|
@ -10,9 +9,6 @@ export default function polls(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case POLLS_IMPORT:
|
case POLLS_IMPORT:
|
||||||
return importPolls(state, action.polls);
|
return importPolls(state, action.polls);
|
||||||
case POLL_VOTE_SUCCESS:
|
|
||||||
case POLL_FETCH_SUCCESS:
|
|
||||||
return importPolls(state, [action.poll]);
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue