diff --git a/config.js b/config.js index 6ca21d64a..49c8ceb60 100644 --- a/config.js +++ b/config.js @@ -385,6 +385,10 @@ var config = { // set or the lobby is not enabled. // enableInsecureRoomNameWarning: false, + // Whether to automatically copy invitation URL after creating a room. + // Document should be focused for this option to work + // enableAutomaticUrlCopy: false, + // Stats // diff --git a/react/features/base/config/configWhitelist.js b/react/features/base/config/configWhitelist.js index 5abd62c2a..73e6381b1 100644 --- a/react/features/base/config/configWhitelist.js +++ b/react/features/base/config/configWhitelist.js @@ -107,6 +107,7 @@ export default [ 'enableNoAudioDetection', 'enableNoisyMicDetection', 'enableTcc', + 'enableAutomaticUrlCopy', 'etherpad_base', 'failICE', 'feedbackPercentage', diff --git a/react/features/base/premeeting/components/web/CopyMeetingUrl.js b/react/features/base/premeeting/components/web/CopyMeetingUrl.js index ed956ea22..f443230c6 100644 --- a/react/features/base/premeeting/components/web/CopyMeetingUrl.js +++ b/react/features/base/premeeting/components/web/CopyMeetingUrl.js @@ -18,7 +18,13 @@ type Props = { /** * Used for translation. */ - t: Function + t: Function, + + /** + * Used to determine if invitation link should be automatically copied + * after creating a meeting. + */ + _enableAutomaticUrlCopy: boolean, }; type State = { @@ -58,6 +64,7 @@ class CopyMeetingUrl extends Component { this._hideLinkCopied = this._hideLinkCopied.bind(this); this._showCopyLink = this._showCopyLink.bind(this); this._showLinkCopied = this._showLinkCopied.bind(this); + this._copyUrlAutomatically = this._copyUrlAutomatically.bind(this); } _copyUrl: () => void; @@ -135,6 +142,37 @@ class CopyMeetingUrl extends Component { }); } + _copyUrlAutomatically: () => void; + + /** + * Attempts to automatically copy invitation URL. + * Document has to be focused in order for this to work. + * + * @private + * @returns {void} + */ + _copyUrlAutomatically() { + navigator.clipboard.writeText(this.props.url) + .then(() => { + this._showLinkCopied(); + window.setTimeout(this._hideLinkCopied, COPY_TIMEOUT); + }); + } + + /** + * Implements React's {@link Component#componentDidMount()}. Invoked + * immediately before mounting occurs. + * + * @inheritdoc + */ + componentDidMount() { + const { _enableAutomaticUrlCopy } = this.props; + + if (_enableAutomaticUrlCopy) { + setTimeout(this._copyUrlAutomatically, 2000); + } + } + /** * Implements React's {@link Component#render()}. * @@ -177,8 +215,11 @@ class CopyMeetingUrl extends Component { * @returns {Object} */ function mapStateToProps(state) { + const { enableAutomaticUrlCopy } = state['features/base/config']; + return { - url: getCurrentConferenceUrl(state) + url: getCurrentConferenceUrl(state), + _enableAutomaticUrlCopy: enableAutomaticUrlCopy || false }; }