bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/captions/pad/container.jsx

56 lines
1.3 KiB
React
Raw Normal View History

import React, { PureComponent } from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import { Session } from 'meteor/session';
import { makeCall } from '/imports/ui/services/api';
import Pad from './component';
import CaptionsService from '/imports/ui/components/captions/service';
class PadContainer extends PureComponent {
render() {
2019-05-29 22:31:27 +08:00
const { children } = this.props;
return (
<Pad {...this.props}>
2019-05-29 22:31:27 +08:00
{children}
</Pad>
);
}
}
export default withTracker(() => {
const locale = Session.get('captionsLocale');
const caption = CaptionsService.getCaptions(locale);
const {
padId,
ownerId,
readOnlyPadId,
} = caption;
2019-05-23 22:51:01 +08:00
const { name } = caption ? caption.locale : '';
const handleAppendText = text => makeCall('appendText', text, locale);
const initVoiceRecognition = () => {
2019-06-14 22:33:46 +08:00
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
let recognition = null;
if (SR) {
recognition = new SR();
recognition.continuous = true;
recognition.interimResults = true;
recognition.lang = locale;
2019-06-14 22:33:46 +08:00
}
2019-06-14 22:33:46 +08:00
return recognition;
};
return {
locale,
2019-05-23 22:51:01 +08:00
name,
ownerId,
padId,
readOnlyPadId,
amIModerator: CaptionsService.amIModerator(),
handleAppendText,
2019-06-14 22:33:46 +08:00
initVoiceRecognition,
};
})(PadContainer);