Merge pull request #15950 from KDSBrowne/bbb-qp-button-update

Allow Poll Start From Smart Slides With Active Poll
This commit is contained in:
Ramón Souza 2022-11-03 15:41:32 -03:00 committed by GitHub
commit 4cd0329ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 19 deletions

View File

@ -8,6 +8,7 @@ import { PANELS, ACTIONS } from '../../layout/enums';
const POLL_SETTINGS = Meteor.settings.public.poll; const POLL_SETTINGS = Meteor.settings.public.poll;
const MAX_CUSTOM_FIELDS = POLL_SETTINGS.maxCustom; const MAX_CUSTOM_FIELDS = POLL_SETTINGS.maxCustom;
const CANCELED_POLL_DELAY = 250;
const intlMessages = defineMessages({ const intlMessages = defineMessages({
quickPollLabel: { quickPollLabel: {
@ -54,6 +55,7 @@ const QuickPollDropdown = (props) => {
intl, intl,
parseCurrentSlideContent, parseCurrentSlideContent,
startPoll, startPoll,
stopPoll,
currentSlide, currentSlide,
activePoll, activePoll,
className, className,
@ -101,8 +103,13 @@ const QuickPollDropdown = (props) => {
label={intl.formatMessage(intlMessages.typedRespLabel)} label={intl.formatMessage(intlMessages.typedRespLabel)}
key={_.uniqueId('quick-poll-item')} key={_.uniqueId('quick-poll-item')}
onClick={() => { onClick={() => {
handleClickQuickPoll(_layoutContextDispatch); if (activePoll) {
funcStartPoll(type, slideId, letterAnswers, pollData?.question); stopPoll();
}
setTimeout(() => {
handleClickQuickPoll(_layoutContextDispatch);
funcStartPoll(type, slideId, letterAnswers, pollData?.question);
}, CANCELED_POLL_DELAY);
}} }}
question={pollData?.question} question={pollData?.question}
/> />
@ -142,8 +149,13 @@ const QuickPollDropdown = (props) => {
label={itemLabel} label={itemLabel}
key={_.uniqueId('quick-poll-item')} key={_.uniqueId('quick-poll-item')}
onClick={() => { onClick={() => {
handleClickQuickPoll(_layoutContextDispatch); if (activePoll) {
funcStartPoll(type, slideId, letterAnswers, pollQuestion, pollData?.multiResp); stopPoll();
}
setTimeout(() => {
handleClickQuickPoll(_layoutContextDispatch);
funcStartPoll(type, slideId, letterAnswers, pollQuestion, pollData?.multiResp);
}, CANCELED_POLL_DELAY);
}} }}
answers={letterAnswers} answers={letterAnswers}
multiResp={pollData?.multiResp} multiResp={pollData?.multiResp}
@ -191,21 +203,26 @@ const QuickPollDropdown = (props) => {
label={quickPollLabel} label={quickPollLabel}
tooltipLabel={intl.formatMessage(intlMessages.quickPollLabel)} tooltipLabel={intl.formatMessage(intlMessages.quickPollLabel)}
onClick={() => { onClick={() => {
handleClickQuickPoll(layoutContextDispatch); if (activePoll) {
if (singlePollType === 'R-' || singlePollType === 'TF') { stopPoll();
startPoll(singlePollType, currentSlide.id, answers, pollQuestion, multiResponse);
} else {
startPoll(
pollTypes.Custom,
currentSlide.id,
optionsWithLabels,
pollQuestion,
multiResponse,
);
} }
setTimeout(() => {
handleClickQuickPoll(layoutContextDispatch);
if (singlePollType === 'R-' || singlePollType === 'TF') {
startPoll(singlePollType, currentSlide.id, answers, pollQuestion, multiResponse);
} else {
startPoll(
pollTypes.Custom,
currentSlide.id,
optionsWithLabels,
pollQuestion,
multiResponse,
);
}
}, CANCELED_POLL_DELAY);
}} }}
size="lg" size="lg"
disabled={!!activePoll}
data-test="quickPollBtn" data-test="quickPollBtn"
/> />
); );
@ -221,7 +238,6 @@ const QuickPollDropdown = (props) => {
tooltipLabel={intl.formatMessage(intlMessages.quickPollLabel)} tooltipLabel={intl.formatMessage(intlMessages.quickPollLabel)}
onClick={() => null} onClick={() => null}
size="lg" size="lg"
disabled={!!activePoll}
/> />
); );

View File

@ -1,17 +1,18 @@
import React from 'react'; import React from 'react';
import { withTracker } from 'meteor/react-meteor-data'; import { withTracker } from 'meteor/react-meteor-data';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
import { makeCall } from '/imports/ui/services/api';
import PollService from '/imports/ui/components/poll/service';
import QuickPollDropdown from './component'; import QuickPollDropdown from './component';
import { layoutDispatch } from '../../layout/context'; import { layoutDispatch } from '../../layout/context';
import PollService from '/imports/ui/components/poll/service';
const QuickPollDropdownContainer = (props) => { const QuickPollDropdownContainer = (props) => {
const layoutContextDispatch = layoutDispatch(); const layoutContextDispatch = layoutDispatch();
return <QuickPollDropdown {...{ layoutContextDispatch, ...props }} />; return <QuickPollDropdown {...{ layoutContextDispatch, ...props }} />;
}; };
export default withTracker(() => ({ export default withTracker(() => ({
activePoll: Session.get('pollInitiated') || false, activePoll: Session.get('pollInitiated') || false,
pollTypes: PollService.pollTypes, pollTypes: PollService.pollTypes,
stopPoll: () => makeCall('stopPoll'),
}))(injectIntl(QuickPollDropdownContainer)); }))(injectIntl(QuickPollDropdownContainer));