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 = {
intl: intlShape.isRequired,
isCaptionsActive: PropTypes.bool.isRequired,
isActive: PropTypes.bool.isRequired,
handleOnClick: PropTypes.func.isRequired,
};
@ -23,19 +23,19 @@ const intlMessages = defineMessages({
},
});
const CaptionsButton = ({ intl, isCaptionsActive, handleOnClick }) => {
const CaptionsButton = ({ intl, isActive, handleOnClick }) => {
return (
<Button
className={cx(styles.button, isCaptionsActive || styles.btn)}
className={cx(styles.button, isActive || styles.btn)}
icon="polling"
label={intl.formatMessage(isCaptionsActive ? intlMessages.stop : intlMessages.start)}
color={isCaptionsActive ? 'primary' : 'default'}
ghost={!isCaptionsActive}
label={intl.formatMessage(isActive ? intlMessages.stop : intlMessages.start)}
color={isActive ? 'primary' : 'default'}
ghost={!isActive}
hideLabel
circle
size="lg"
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} />;
export default withModalMounter(withTracker(({ mountModal }) => ({
isCaptionsActive: CaptionsService.getActiveCaptions() ? true : false,
handleOnClick: () => (CaptionsService.getActiveCaptions() ? CaptionsService.deactivateCaptions() : mountModal(<CaptionsReaderMenuContainer />)),
isActive: CaptionsService.isCaptionsActive(),
handleOnClick: () => (CaptionsService.isCaptionsActive() ? CaptionsService.deactivateCaptions() : mountModal(<CaptionsReaderMenuContainer />)),
}))(CaptionsButtonContainer));

View File

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

View File

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

View File

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