Pārlūkot izejas kodu

fix(prejoin): copy meeting info

j8
Vlad Piersec 5 gadus atpakaļ
vecāks
revīzija
87b14c3711

+ 3
- 16
react/features/base/premeeting/components/web/CopyMeetingUrl.js Parādīt failu

6
 import { translate } from '../../../i18n';
6
 import { translate } from '../../../i18n';
7
 import { Icon, IconCopy, IconCheck } from '../../../icons';
7
 import { Icon, IconCopy, IconCheck } from '../../../icons';
8
 import { connect } from '../../../redux';
8
 import { connect } from '../../../redux';
9
-import logger from '../../logger';
9
+import { copyText } from '../../../util';
10
 
10
 
11
 type Props = {
11
 type Props = {
12
 
12
 
41
  */
41
  */
42
 class CopyMeetingUrl extends Component<Props, State> {
42
 class CopyMeetingUrl extends Component<Props, State> {
43
 
43
 
44
-    textarea: Object;
45
-
46
     /**
44
     /**
47
      * Initializes a new {@code Prejoin} instance.
45
      * Initializes a new {@code Prejoin} instance.
48
      *
46
      *
51
     constructor(props) {
49
     constructor(props) {
52
         super(props);
50
         super(props);
53
 
51
 
54
-        this.textarea = React.createRef();
55
         this.state = {
52
         this.state = {
56
             showCopyLink: false,
53
             showCopyLink: false,
57
             showLinkCopied: false
54
             showLinkCopied: false
71
      * @returns {void}
68
      * @returns {void}
72
      */
69
      */
73
     _copyUrl() {
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
             this._showLinkCopied();
74
             this._showLinkCopied();
81
             window.setTimeout(this._hideLinkCopied, COPY_TIMEOUT);
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
                         size = { 24 }
165
                         size = { 24 }
174
                         src = { src } />
166
                         src = { src } />
175
                 </div>
167
                 </div>
176
-                <textarea
177
-                    readOnly = { true }
178
-                    ref = { this.textarea }
179
-                    tabIndex = '-1'
180
-                    value = { url } />
181
             </div>
168
             </div>
182
         );
169
         );
183
     }
170
     }

+ 28
- 0
react/features/base/util/helpers.js Parādīt failu

24
     return to;
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
  * Creates a deferred object.
56
  * Creates a deferred object.
29
  *
57
  *

+ 1
- 1
react/features/invite/components/add-people-dialog/web/CopyMeetingLinkSection.js Parādīt failu

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

+ 1
- 2
react/features/invite/components/add-people-dialog/web/DialInNumber.js Parādīt failu

4
 
4
 
5
 import { translate } from '../../../../base/i18n';
5
 import { translate } from '../../../../base/i18n';
6
 import { Icon, IconCopy } from '../../../../base/icons';
6
 import { Icon, IconCopy } from '../../../../base/icons';
7
+import { copyText } from '../../../../base/util';
7
 import { _formatConferenceIDPin } from '../../../_utils';
8
 import { _formatConferenceIDPin } from '../../../_utils';
8
 
9
 
9
-import { copyText } from './utils';
10
-
11
 /**
10
 /**
12
  * The type of the React {@code Component} props of {@link DialInNumber}.
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 Parādīt failu

13
     IconOutlook,
13
     IconOutlook,
14
     IconYahoo
14
     IconYahoo
15
 } from '../../../../base/icons';
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
 type Props = {
18
 type Props = {
21
 
19
 

+ 1
- 2
react/features/invite/components/add-people-dialog/web/LiveStreamSection.js Parādīt failu

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

+ 0
- 1
react/features/invite/components/add-people-dialog/web/index.js Parādīt failu

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

+ 0
- 23
react/features/invite/components/add-people-dialog/web/utils.js Parādīt failu

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
-}

Notiek ielāde…
Atcelt
Saglabāt