Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(prejoin): copy meeting info
Vlad Piersec87b14c37119b
diff --git a/react/features/base/premeeting/components/web/CopyMeetingUrl.js b/react/features/base/premeeting/components/web/CopyMeetingUrl.jsindex 1094533a0b..7725ab4264 100644--- a/react/features/base/premeeting/components/web/CopyMeetingUrl.js+++ b/react/features/base/premeeting/components/web/CopyMeetingUrl.js@@ -6,7 +6,7 @@ import { getCurrentConferenceUrl } from '../../../connection';import { translate } from '../../../i18n';import { Icon, IconCopy, IconCheck } from '../../../icons';import { connect } from '../../../redux';-import logger from '../../logger';+import { copyText } from '../../../util';type Props = {@@ -41,8 +41,6 @@ const COPY_TIMEOUT = 2000;*/class CopyMeetingUrl extends Component<Props, State> {- textarea: Object;-/*** Initializes a new {@code Prejoin} instance.*@@ -51,7 +49,6 @@ class CopyMeetingUrl extends Component<Props, State> {constructor(props) {super(props);- this.textarea = React.createRef();this.state = {showCopyLink: false,showLinkCopied: false@@ -71,16 +68,11 @@ class CopyMeetingUrl extends Component<Props, State> {* @returns {void}*/_copyUrl() {- const textarea = this.textarea.current;+ const success = copyText(this.props.url);- try {- textarea.select();- document.execCommand('copy');- textarea.blur();+ if (success) {this._showLinkCopied();window.setTimeout(this._hideLinkCopied, COPY_TIMEOUT);- } catch (err) {- logger.error('error when copying the meeting url');}}@@ -173,11 +165,6 @@ class CopyMeetingUrl extends Component<Props, State> {size = { 24 }src = { src } /></div>- <textarea- readOnly = { true }- ref = { this.textarea }- tabIndex = '-1'- value = { url } /></div>);}diff --git a/react/features/base/util/helpers.js b/react/features/base/util/helpers.jsindex a990dbee8e..53c41780c4 100644--- a/react/features/base/util/helpers.js+++ b/react/features/base/util/helpers.js@@ -24,6 +24,34 @@ export function assignIfDefined(target: Object, source: Object) {return to;}+/**+ * Tries to copy a given text to the clipboard.+ * Returns true if the action succeeds.+ *+ * @param {string} textToCopy - Text to be copied.+ * @returns {boolean}+ */+export function copyText(textToCopy: string) {+ const fakeTextArea = document.createElement('textarea');+ let result;++ // $FlowFixMe+ document.body.appendChild(fakeTextArea);+ fakeTextArea.value = textToCopy;+ fakeTextArea.select();++ try {+ result = document.execCommand('copy');+ } catch (err) {+ result = false;+ }++ // $FlowFixMe+ document.body.removeChild(fakeTextArea);++ return result;+}+/*** Creates a deferred object.*diff --git a/react/features/invite/components/add-people-dialog/web/CopyMeetingLinkSection.js b/react/features/invite/components/add-people-dialog/web/CopyMeetingLinkSection.jsindex e688230cfc..baacd2db7d 100644--- a/react/features/invite/components/add-people-dialog/web/CopyMeetingLinkSection.js+++ b/react/features/invite/components/add-people-dialog/web/CopyMeetingLinkSection.js@@ -4,8 +4,8 @@ import React, { useState } from 'react';import { translate } from '../../../../base/i18n';import { Icon, IconCheck, IconCopy } from '../../../../base/icons';+import { copyText } from '../../../../base/util';-import { copyText } from './utils';type Props = {diff --git a/react/features/invite/components/add-people-dialog/web/DialInNumber.js b/react/features/invite/components/add-people-dialog/web/DialInNumber.jsindex e3829e1eb7..fc470e97d4 100644--- a/react/features/invite/components/add-people-dialog/web/DialInNumber.js+++ b/react/features/invite/components/add-people-dialog/web/DialInNumber.js@@ -4,10 +4,9 @@ import React, { Component } from 'react';import { translate } from '../../../../base/i18n';import { Icon, IconCopy } from '../../../../base/icons';+import { copyText } from '../../../../base/util';import { _formatConferenceIDPin } from '../../../_utils';-import { copyText } from './utils';-/*** The type of the React {@code Component} props of {@link DialInNumber}.*/diff --git a/react/features/invite/components/add-people-dialog/web/InviteByEmailSection.js b/react/features/invite/components/add-people-dialog/web/InviteByEmailSection.jsindex 4fda2c7ab0..02f1b1eeb9 100644--- a/react/features/invite/components/add-people-dialog/web/InviteByEmailSection.js+++ b/react/features/invite/components/add-people-dialog/web/InviteByEmailSection.js@@ -13,9 +13,7 @@ import {IconOutlook,IconYahoo} from '../../../../base/icons';-import { openURLInBrowser } from '../../../../base/util';--import { copyText } from './utils';+import { copyText, openURLInBrowser } from '../../../../base/util';type Props = {diff --git a/react/features/invite/components/add-people-dialog/web/LiveStreamSection.js b/react/features/invite/components/add-people-dialog/web/LiveStreamSection.jsindex 16a57e551d..f535733225 100644--- a/react/features/invite/components/add-people-dialog/web/LiveStreamSection.js+++ b/react/features/invite/components/add-people-dialog/web/LiveStreamSection.js@@ -4,8 +4,7 @@ import React, { useState } from 'react';import { translate } from '../../../../base/i18n';import { Icon, IconCheck, IconCopy } from '../../../../base/icons';--import { copyText } from './utils';+import { copyText } from '../../../../base/util';type Props = {diff --git a/react/features/invite/components/add-people-dialog/web/index.js b/react/features/invite/components/add-people-dialog/web/index.jsindex f432fcb95a..f2e67e6310 100644--- a/react/features/invite/components/add-people-dialog/web/index.js+++ b/react/features/invite/components/add-people-dialog/web/index.js@@ -1,4 +1,3 @@// @flowexport { default as AddPeopleDialog } from './AddPeopleDialog';-export * from './utils';diff --git a/react/features/invite/components/add-people-dialog/web/utils.js b/react/features/invite/components/add-people-dialog/web/utils.jsdeleted file mode 100644index 46f3c6505d..0000000000--- a/react/features/invite/components/add-people-dialog/web/utils.js+++ /dev/null@@ -1,23 +0,0 @@-// @flow--/**- * Tries to copy a given text to the clipboard.- *- * @param {string} textToCopy - Text to be copied.- * @returns {boolean}- */-export function copyText(textToCopy: string) {- const fakeTextArea = document.createElement('textarea');-- // $FlowFixMe- document.body.appendChild(fakeTextArea);- fakeTextArea.value = textToCopy;- fakeTextArea.select();-- const result = document.execCommand('copy');-- // $FlowFixMe- document.body.removeChild(fakeTextArea);-- return result;-}