ソースを参照

fix(prejoin): copy meeting info

j8
Vlad Piersec 5年前
コミット
87b14c3711

+ 3
- 16
react/features/base/premeeting/components/web/CopyMeetingUrl.js ファイルの表示

@@ -6,7 +6,7 @@ import { getCurrentConferenceUrl } from '../../../connection';
6 6
 import { translate } from '../../../i18n';
7 7
 import { Icon, IconCopy, IconCheck } from '../../../icons';
8 8
 import { connect } from '../../../redux';
9
-import logger from '../../logger';
9
+import { copyText } from '../../../util';
10 10
 
11 11
 type Props = {
12 12
 
@@ -41,8 +41,6 @@ const COPY_TIMEOUT = 2000;
41 41
  */
42 42
 class CopyMeetingUrl extends Component<Props, State> {
43 43
 
44
-    textarea: Object;
45
-
46 44
     /**
47 45
      * Initializes a new {@code Prejoin} instance.
48 46
      *
@@ -51,7 +49,6 @@ class CopyMeetingUrl extends Component<Props, State> {
51 49
     constructor(props) {
52 50
         super(props);
53 51
 
54
-        this.textarea = React.createRef();
55 52
         this.state = {
56 53
             showCopyLink: false,
57 54
             showLinkCopied: false
@@ -71,16 +68,11 @@ class CopyMeetingUrl extends Component<Props, State> {
71 68
      * @returns {void}
72 69
      */
73 70
     _copyUrl() {
74
-        const textarea = this.textarea.current;
71
+        const success = copyText(this.props.url);
75 72
 
76
-        try {
77
-            textarea.select();
78
-            document.execCommand('copy');
79
-            textarea.blur();
73
+        if (success) {
80 74
             this._showLinkCopied();
81 75
             window.setTimeout(this._hideLinkCopied, COPY_TIMEOUT);
82
-        } catch (err) {
83
-            logger.error('error when copying the meeting url');
84 76
         }
85 77
     }
86 78
 
@@ -173,11 +165,6 @@ class CopyMeetingUrl extends Component<Props, State> {
173 165
                         size = { 24 }
174 166
                         src = { src } />
175 167
                 </div>
176
-                <textarea
177
-                    readOnly = { true }
178
-                    ref = { this.textarea }
179
-                    tabIndex = '-1'
180
-                    value = { url } />
181 168
             </div>
182 169
         );
183 170
     }

+ 28
- 0
react/features/base/util/helpers.js ファイルの表示

@@ -24,6 +24,34 @@ export function assignIfDefined(target: Object, source: Object) {
24 24
     return to;
25 25
 }
26 26
 
27
+/**
28
+ * Tries to copy a given text to the clipboard.
29
+ * Returns true if the action succeeds.
30
+ *
31
+ * @param {string} textToCopy - Text to be copied.
32
+ * @returns {boolean}
33
+ */
34
+export function copyText(textToCopy: string) {
35
+    const fakeTextArea = document.createElement('textarea');
36
+    let result;
37
+
38
+    // $FlowFixMe
39
+    document.body.appendChild(fakeTextArea);
40
+    fakeTextArea.value = textToCopy;
41
+    fakeTextArea.select();
42
+
43
+    try {
44
+        result = document.execCommand('copy');
45
+    } catch (err) {
46
+        result = false;
47
+    }
48
+
49
+    // $FlowFixMe
50
+    document.body.removeChild(fakeTextArea);
51
+
52
+    return result;
53
+}
54
+
27 55
 /**
28 56
  * Creates a deferred object.
29 57
  *

+ 1
- 1
react/features/invite/components/add-people-dialog/web/CopyMeetingLinkSection.js ファイルの表示

@@ -4,8 +4,8 @@ import React, { useState } from 'react';
4 4
 
5 5
 import { translate } from '../../../../base/i18n';
6 6
 import { Icon, IconCheck, IconCopy } from '../../../../base/icons';
7
+import { copyText } from '../../../../base/util';
7 8
 
8
-import { copyText } from './utils';
9 9
 
10 10
 type Props = {
11 11
 

+ 1
- 2
react/features/invite/components/add-people-dialog/web/DialInNumber.js ファイルの表示

@@ -4,10 +4,9 @@ import React, { Component } from 'react';
4 4
 
5 5
 import { translate } from '../../../../base/i18n';
6 6
 import { Icon, IconCopy } from '../../../../base/icons';
7
+import { copyText } from '../../../../base/util';
7 8
 import { _formatConferenceIDPin } from '../../../_utils';
8 9
 
9
-import { copyText } from './utils';
10
-
11 10
 /**
12 11
  * The type of the React {@code Component} props of {@link DialInNumber}.
13 12
  */

+ 1
- 3
react/features/invite/components/add-people-dialog/web/InviteByEmailSection.js ファイルの表示

@@ -13,9 +13,7 @@ import {
13 13
     IconOutlook,
14 14
     IconYahoo
15 15
 } from '../../../../base/icons';
16
-import { openURLInBrowser } from '../../../../base/util';
17
-
18
-import { copyText } from './utils';
16
+import { copyText, openURLInBrowser } from '../../../../base/util';
19 17
 
20 18
 type Props = {
21 19
 

+ 1
- 2
react/features/invite/components/add-people-dialog/web/LiveStreamSection.js ファイルの表示

@@ -4,8 +4,7 @@ import React, { useState } from 'react';
4 4
 
5 5
 import { translate } from '../../../../base/i18n';
6 6
 import { Icon, IconCheck, IconCopy } from '../../../../base/icons';
7
-
8
-import { copyText } from './utils';
7
+import { copyText } from '../../../../base/util';
9 8
 
10 9
 type Props = {
11 10
 

+ 0
- 1
react/features/invite/components/add-people-dialog/web/index.js ファイルの表示

@@ -1,4 +1,3 @@
1 1
 // @flow
2 2
 
3 3
 export { default as AddPeopleDialog } from './AddPeopleDialog';
4
-export * from './utils';

+ 0
- 23
react/features/invite/components/add-people-dialog/web/utils.js ファイルの表示

@@ -1,23 +0,0 @@
1
-// @flow
2
-
3
-/**
4
- * Tries to copy a given text to the clipboard.
5
- *
6
- * @param {string} textToCopy - Text to be copied.
7
- * @returns {boolean}
8
- */
9
-export function copyText(textToCopy: string) {
10
-    const fakeTextArea = document.createElement('textarea');
11
-
12
-    // $FlowFixMe
13
-    document.body.appendChild(fakeTextArea);
14
-    fakeTextArea.value = textToCopy;
15
-    fakeTextArea.select();
16
-
17
-    const result = document.execCommand('copy');
18
-
19
-    // $FlowFixMe
20
-    document.body.removeChild(fakeTextArea);
21
-
22
-    return result;
23
-}

読み込み中…
キャンセル
保存