88 lines
2.4 KiB
JavaScript
Executable file
88 lines
2.4 KiB
JavaScript
Executable file
import React from 'react';
|
|
import i18n from '../i18n';
|
|
import Flux from '../lib/flux/index';
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
import ScreenshareModalStore from '../stores/ScreenshareModalStore';
|
|
import UserSettingsStore from '../stores/UserSettingsStore';
|
|
import ScreenshareModalActionCreators from '../actions/web/ScreenshareModalActionCreators';
|
|
import AudioActionCreators from '../actions/AudioActionCreators';
|
|
import SelectedChannelActionCreators from '../actions/SelectedChannelActionCreators';
|
|
import CallActionCreators from '../actions/CallActionCreators';
|
|
import UIKitScreenshareModal from '../uikit/ScreenshareModal';
|
|
import Grid from '../uikit/Grid';
|
|
import {MediaEngineDesktopSources} from '../lib/MediaEngine';
|
|
|
|
const ScreenshareModal = React.createClass({
|
|
statics: {
|
|
modalConfig: {
|
|
store: ScreenshareModalStore,
|
|
},
|
|
},
|
|
|
|
mixins: [Flux.LazyStoreListenerMixin(UserSettingsStore), PureRenderMixin],
|
|
|
|
getInitialState() {
|
|
return this.getStateFromStores();
|
|
},
|
|
|
|
getStateFromStores() {
|
|
return {
|
|
theme: UserSettingsStore.theme,
|
|
};
|
|
},
|
|
|
|
getItems() {
|
|
return [
|
|
{
|
|
name: i18n.Messages.SCREENSHARE_SCREEN,
|
|
value: MediaEngineDesktopSources.SCREEN,
|
|
layout: Grid.Layout.STACK,
|
|
options: this.props.screenSources,
|
|
},
|
|
{
|
|
name: i18n.Messages.SCREENSHARE_WINDOW,
|
|
value: MediaEngineDesktopSources.WINDOW,
|
|
layout: Grid.Layout.WRAP,
|
|
options: this.props.windowSources,
|
|
},
|
|
];
|
|
},
|
|
|
|
close() {
|
|
ScreenshareModalActionCreators.close();
|
|
},
|
|
|
|
handleShare(sourceId) {
|
|
this.close();
|
|
const {channel, startCall} = this.props;
|
|
AudioActionCreators.setDesktopSource(sourceId);
|
|
|
|
if (startCall) {
|
|
SelectedChannelActionCreators.selectVoiceChannel(null, channel.id);
|
|
if (!channel.isManaged()) {
|
|
CallActionCreators.ring(channel.id);
|
|
}
|
|
}
|
|
},
|
|
|
|
render() {
|
|
return (
|
|
<div className={`theme-${this.state.theme}`}>
|
|
<UIKitScreenshareModal
|
|
items={this.getItems()}
|
|
value={MediaEngineDesktopSources.SCREEN}
|
|
description={i18n.Messages.SCREENSHARE_DESCRIPTION.format({name: this.props.channel.toString()})}
|
|
onCancel={this.close}
|
|
onSelect={this.handleShare}
|
|
/>
|
|
</div>
|
|
);
|
|
},
|
|
});
|
|
|
|
export default ScreenshareModal;
|
|
|
|
|
|
|
|
// WEBPACK FOOTER //
|
|
// ./discord_app/components/ScreenshareModal.js
|