fix(prejoin): copy meeting info
This commit is contained in:
parent
5811e0476c
commit
87b14c3711
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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 = {
|
||||
|
||||
|
|
|
@ -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}.
|
||||
*/
|
||||
|
|
|
@ -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 = {
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// @flow
|
||||
|
||||
export { default as AddPeopleDialog } from './AddPeopleDialog';
|
||||
export * from './utils';
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue