|
|
|
@ -5,6 +5,7 @@ import type { AbstractComponent } from 'react'; |
|
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
import { useSelector } from 'react-redux'; |
|
|
|
|
|
|
|
|
|
import { sendAnalytics, createPollEvent } from '../../analytics'; |
|
|
|
|
import { getParticipantDisplayName } from '../../base/participants'; |
|
|
|
|
import { COMMAND_NEW_POLL } from '../constants'; |
|
|
|
|
|
|
|
|
@ -55,18 +56,18 @@ const AbstractPollCreate = (Component: AbstractComponent<AbstractProps>) => (pro |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const addAnswer = useCallback((i: ?number) => { |
|
|
|
|
|
|
|
|
|
const newAnswers = [ ...answers ]; |
|
|
|
|
|
|
|
|
|
sendAnalytics(createPollEvent('option.added')); |
|
|
|
|
newAnswers.splice(typeof i === 'number' ? i : answers.length, 0, ''); |
|
|
|
|
setAnswers(newAnswers); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const moveAnswer = useCallback((i, j) => { |
|
|
|
|
const newAnswers = [ ...answers ]; |
|
|
|
|
|
|
|
|
|
const answer = answers[i]; |
|
|
|
|
|
|
|
|
|
sendAnalytics(createPollEvent('option.moved')); |
|
|
|
|
newAnswers.splice(i, 1); |
|
|
|
|
newAnswers.splice(j, 0, answer); |
|
|
|
|
setAnswers(newAnswers); |
|
|
|
@ -78,6 +79,7 @@ const AbstractPollCreate = (Component: AbstractComponent<AbstractProps>) => (pro |
|
|
|
|
} |
|
|
|
|
const newAnswers = [ ...answers ]; |
|
|
|
|
|
|
|
|
|
sendAnalytics(createPollEvent('option.removed')); |
|
|
|
|
newAnswers.splice(i, 1); |
|
|
|
|
setAnswers(newAnswers); |
|
|
|
|
}); |
|
|
|
@ -105,6 +107,7 @@ const AbstractPollCreate = (Component: AbstractComponent<AbstractProps>) => (pro |
|
|
|
|
question, |
|
|
|
|
answers: filteredAnswers |
|
|
|
|
}); |
|
|
|
|
sendAnalytics(createPollEvent('created')); |
|
|
|
|
|
|
|
|
|
setCreateMode(false); |
|
|
|
|
|
|
|
|
|