Better management of captions activation

This commit is contained in:
Pedro Beschorner Marin 2019-05-17 17:02:28 -03:00
parent 34b39a2b0a
commit a37ae9cb70
5 changed files with 12 additions and 14 deletions

View File

@ -8,7 +8,7 @@ import Button from '/imports/ui/components/button/component';
const propTypes = { const propTypes = {
intl: intlShape.isRequired, intl: intlShape.isRequired,
isCaptionsActive: PropTypes.bool.isRequired, isActive: PropTypes.bool.isRequired,
handleOnClick: PropTypes.func.isRequired, handleOnClick: PropTypes.func.isRequired,
}; };
@ -23,19 +23,19 @@ const intlMessages = defineMessages({
}, },
}); });
const CaptionsButton = ({ intl, isCaptionsActive, handleOnClick }) => { const CaptionsButton = ({ intl, isActive, handleOnClick }) => {
return ( return (
<Button <Button
className={cx(styles.button, isCaptionsActive || styles.btn)} className={cx(styles.button, isActive || styles.btn)}
icon="polling" icon="polling"
label={intl.formatMessage(isCaptionsActive ? intlMessages.stop : intlMessages.start)} label={intl.formatMessage(isActive ? intlMessages.stop : intlMessages.start)}
color={isCaptionsActive ? 'primary' : 'default'} color={isActive ? 'primary' : 'default'}
ghost={!isCaptionsActive} ghost={!isActive}
hideLabel hideLabel
circle circle
size="lg" size="lg"
onClick={handleOnClick} onClick={handleOnClick}
id={isCaptionsActive ? 'stop-captions-button' : 'start-captions-button'} id={isActive ? 'stop-captions-button' : 'start-captions-button'}
/> />
); );
}; };

View File

@ -8,6 +8,6 @@ import CaptionsButton from './component';
const CaptionsButtonContainer = props => <CaptionsButton {...props} />; const CaptionsButtonContainer = props => <CaptionsButton {...props} />;
export default withModalMounter(withTracker(({ mountModal }) => ({ export default withModalMounter(withTracker(({ mountModal }) => ({
isCaptionsActive: CaptionsService.getActiveCaptions() ? true : false, isActive: CaptionsService.isCaptionsActive(),
handleOnClick: () => (CaptionsService.getActiveCaptions() ? CaptionsService.deactivateCaptions() : mountModal(<CaptionsReaderMenuContainer />)), handleOnClick: () => (CaptionsService.isCaptionsActive() ? CaptionsService.deactivateCaptions() : mountModal(<CaptionsReaderMenuContainer />)),
}))(CaptionsButtonContainer)); }))(CaptionsButtonContainer));

View File

@ -90,7 +90,7 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls })
}).fetch(); }).fetch();
return { return {
captions: CaptionsService.isCaptionsActive ? <CaptionsContainer /> : null, captions: CaptionsService.isCaptionsActive() ? <CaptionsContainer /> : null,
fontSize: getFontSize(), fontSize: getFontSize(),
hasBreakoutRooms: getBreakoutRooms().length > 0, hasBreakoutRooms: getBreakoutRooms().length > 0,
customStyle: getFromUserSettings('customStyle', false), customStyle: getFromUserSettings('customStyle', false),

View File

@ -23,6 +23,6 @@ export default withTracker(() => {
fontColor, fontColor,
backgroundColor, backgroundColor,
captions, captions,
isActive: CaptionsService.getActiveCaptions() ? true : false, isActive: CaptionsService.isCaptionsActive(),
}; };
})(CaptionsContainer); })(CaptionsContainer);

View File

@ -92,7 +92,7 @@ const isCaptionsAvailable = () => {
const isCaptionsActive = () => { const isCaptionsActive = () => {
const enabled = isCaptionsEnabled(); const enabled = isCaptionsEnabled();
const activated = getActiveCaptions(); const activated = getActiveCaptions() !== '';
return (enabled && activated); return (enabled && activated);
} }
@ -112,8 +112,6 @@ export default {
takeOwnership, takeOwnership,
getCaptions, getCaptions,
canIOwnThisPad, canIOwnThisPad,
getActiveCaptions,
setActiveCaptions,
getCaptionsSettings, getCaptionsSettings,
isCaptionsEnabled, isCaptionsEnabled,
isCaptionsAvailable, isCaptionsAvailable,