Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(Polls): Display creator name for polls
Vlad Piersece51655a93afe
diff --git a/css/_polls.scss b/css/_polls.scssindex 607bfc7372..8e9c7c2c49 100644--- a/css/_polls.scss+++ b/css/_polls.scss@@ -21,6 +21,12 @@margin-bottom: 8px;}+.poll-creator {+ color: #C2C2C2;+ font-weight: 600;+ margin: 4px 0 16px 0;+}+.poll-answer-container {background: #3D3D3D;border-radius: 3px;@@ -134,7 +140,7 @@ ol.poll-result-list {.poll-question {font-size: 16px;font-weight: 600;- margin-bottom: 16px;+ line-height: 26px;}.poll-answer-voters {diff --git a/lang/main.json b/lang/main.jsonindex 83168203cc..56443f5f54 100644--- a/lang/main.json+++ b/lang/main.json@@ -634,6 +634,7 @@"passwordSetRemotely": "Set by another participant","passwordDigitsOnly": "Up to {{number}} digits","polls": {+ "by": "By {{ name }}","create": {"addOption": "Add option","answerPlaceholder": "Option {{index}}",diff --git a/react/features/base/util/hooks.js b/react/features/base/util/hooks.jsnew file mode 100644index 0000000000..c5a1dd77ea--- /dev/null+++ b/react/features/base/util/hooks.js@@ -0,0 +1,13 @@+// @flow+import { useSelector } from 'react-redux';++/**+ * Takes a redux selector and binds it to specific values.+ *+ * @param {Function} selector - The selector function.+ * @param {...any} args - The values to bind to.+ * @returns {any}+ */+export function useBoundSelector(selector: Function, ...args: any[]) {+ return useSelector(state => selector(state, ...args));+}diff --git a/react/features/polls/components/AbstractPollAnswer.js b/react/features/polls/components/AbstractPollAnswer.jsindex e0f5e7cbc6..1c5d257c15 100644--- a/react/features/polls/components/AbstractPollAnswer.js+++ b/react/features/polls/components/AbstractPollAnswer.js@@ -7,6 +7,7 @@ import { useDispatch, useSelector } from 'react-redux';import { sendAnalytics, createPollEvent } from '../../analytics';import { getLocalParticipant, getParticipantById } from '../../base/participants';+import { useBoundSelector } from '../../base/util/hooks';import { registerVote, setVoteChanging } from '../actions';import { COMMAND_ANSWER_POLL } from '../constants';import type { Poll } from '../types';@@ -24,6 +25,7 @@ type InputProps = {**/export type AbstractProps = {checkBoxStates: Function,+ creatorName: string,poll: Poll,setCheckbox: Function,skipAnswer: Function,@@ -56,6 +58,7 @@ const AbstractPollAnswer = (Component: AbstractComponent<AbstractProps>) => (proreturn new Array(poll.answers.length).fill(false);});+ const participant = useBoundSelector(getParticipantById, poll.senderId);const setCheckbox = useCallback((index, state) => {const newCheckBoxStates = [ ...checkBoxStates ];@@ -67,7 +70,7 @@ const AbstractPollAnswer = (Component: AbstractComponent<AbstractProps>) => (proconst dispatch = useDispatch();- const localParticipant = useSelector(state => getParticipantById(state, localId));+ const localParticipant = useBoundSelector(getParticipantById, localId);const localName: string = localParticipant.name ? localParticipant.name : 'Fellow Jitster';const submitAnswer = useCallback(() => {@@ -99,6 +102,7 @@ const AbstractPollAnswer = (Component: AbstractComponent<AbstractProps>) => (proreturn (<ComponentcheckBoxStates = { checkBoxStates }+ creatorName = { participant ? participant.name : '' }poll = { poll }setCheckbox = { setCheckbox }skipAnswer = { skipAnswer }diff --git a/react/features/polls/components/AbstractPollResults.js b/react/features/polls/components/AbstractPollResults.jsindex 939849fa14..9dd939d967 100644--- a/react/features/polls/components/AbstractPollResults.js+++ b/react/features/polls/components/AbstractPollResults.js@@ -6,6 +6,8 @@ import { useTranslation } from 'react-i18next';import { useDispatch, useSelector } from 'react-redux';import { sendAnalytics, createPollEvent } from '../../analytics';+import { getParticipantById } from '../../base/participants/functions';+import { useBoundSelector } from '../../base/util/hooks';import { setVoteChanging } from '../actions';import { getPoll } from '../functions';@@ -33,6 +35,7 @@ export type AnswerInfo = {export type AbstractProps = {answers: Array<AnswerInfo>,changeVote: Function,+ creatorName: string,showDetails: boolean,question: string,t: Function,@@ -51,6 +54,7 @@ const AbstractPollResults = (Component: AbstractComponent<AbstractProps>) => (prconst { pollId } = props;const pollDetails = useSelector(getPoll(pollId));+ const participant = useBoundSelector(getParticipantById, pollDetails.senderId);const [ showDetails, setShowDetails ] = useState(false);const toggleIsDetailed = useCallback(() => {@@ -105,6 +109,7 @@ const AbstractPollResults = (Component: AbstractComponent<AbstractProps>) => (pr<Componentanswers = { answers }changeVote = { changeVote }+ creatorName = { participant ? participant.name : '' }haveVoted = { pollDetails.lastVote !== null }question = { pollDetails.question }showDetails = { showDetails }diff --git a/react/features/polls/components/web/PollAnswer.js b/react/features/polls/components/web/PollAnswer.jsindex 5690f118f9..a2d5c47303 100644--- a/react/features/polls/components/web/PollAnswer.js+++ b/react/features/polls/components/web/PollAnswer.js@@ -9,6 +9,7 @@ import type { AbstractProps } from '../AbstractPollAnswer';const PollAnswer = (props: AbstractProps) => {const {+ creatorName,checkBoxStates,poll,setCheckbox,@@ -25,6 +26,9 @@ const PollAnswer = (props: AbstractProps) => {<div className = 'poll-question'><span>{ poll.question }</span></div>+ <div className = 'poll-creator'>+ { t('polls.by', { name: creatorName }) }+ </div></div><ol className = 'poll-answer-list'>{diff --git a/react/features/polls/components/web/PollResults.js b/react/features/polls/components/web/PollResults.jsindex 3368912068..0e7f31bb3a 100644--- a/react/features/polls/components/web/PollResults.js+++ b/react/features/polls/components/web/PollResults.js@@ -16,6 +16,7 @@ const PollResults = (props: AbstractProps) => {const {answers,changeVote,+ creatorName,haveVoted,showDetails,question,@@ -29,6 +30,9 @@ const PollResults = (props: AbstractProps) => {<div className = 'poll-question'><strong>{ question }</strong></div>+ <div className = 'poll-creator'>+ { t('polls.by', { name: creatorName }) }+ </div></div><ol className = 'poll-result-list'>{answers.map(({ name, percentage, voters, voterCount }, index) =>