Browse Source

FEAT: Automatically copy invite URL after creating a room (#7581)

* Resolves #7501
- Automatically copy invite URL after creating a room

* Resolves #7501
- Automatically copy invite URL after creating a room

* - Adding config flag to enable the feature
j8
RabeeAbuBaker 5 years ago
parent
commit
79c1358f4b
No account linked to committer's email address

+ 4
- 0
config.js View File

@@ -385,6 +385,10 @@ var config = {
385 385
     // set or the lobby is not enabled.
386 386
     // enableInsecureRoomNameWarning: false,
387 387
 
388
+    // Whether to automatically copy invitation URL after creating a room.
389
+    // Document should be focused for this option to work
390
+    // enableAutomaticUrlCopy: false,
391
+
388 392
     // Stats
389 393
     //
390 394
 

+ 1
- 0
react/features/base/config/configWhitelist.js View File

@@ -107,6 +107,7 @@ export default [
107 107
     'enableNoAudioDetection',
108 108
     'enableNoisyMicDetection',
109 109
     'enableTcc',
110
+    'enableAutomaticUrlCopy',
110 111
     'etherpad_base',
111 112
     'failICE',
112 113
     'feedbackPercentage',

+ 43
- 2
react/features/base/premeeting/components/web/CopyMeetingUrl.js View File

@@ -18,7 +18,13 @@ type Props = {
18 18
     /**
19 19
      * Used for translation.
20 20
      */
21
-    t: Function
21
+    t: Function,
22
+
23
+    /**
24
+     * Used to determine if invitation link should be automatically copied
25
+     * after creating a meeting.
26
+     */
27
+    _enableAutomaticUrlCopy: boolean,
22 28
 };
23 29
 
24 30
 type State = {
@@ -58,6 +64,7 @@ class CopyMeetingUrl extends Component<Props, State> {
58 64
         this._hideLinkCopied = this._hideLinkCopied.bind(this);
59 65
         this._showCopyLink = this._showCopyLink.bind(this);
60 66
         this._showLinkCopied = this._showLinkCopied.bind(this);
67
+        this._copyUrlAutomatically = this._copyUrlAutomatically.bind(this);
61 68
     }
62 69
 
63 70
     _copyUrl: () => void;
@@ -135,6 +142,37 @@ class CopyMeetingUrl extends Component<Props, State> {
135 142
         });
136 143
     }
137 144
 
145
+    _copyUrlAutomatically: () => void;
146
+
147
+    /**
148
+     * Attempts to automatically copy invitation URL.
149
+     * Document has to be focused in order for this to work.
150
+     *
151
+     * @private
152
+     * @returns {void}
153
+     */
154
+    _copyUrlAutomatically() {
155
+        navigator.clipboard.writeText(this.props.url)
156
+            .then(() => {
157
+                this._showLinkCopied();
158
+                window.setTimeout(this._hideLinkCopied, COPY_TIMEOUT);
159
+            });
160
+    }
161
+
162
+    /**
163
+     * Implements React's {@link Component#componentDidMount()}. Invoked
164
+     * immediately before mounting occurs.
165
+     *
166
+     * @inheritdoc
167
+     */
168
+    componentDidMount() {
169
+        const { _enableAutomaticUrlCopy } = this.props;
170
+
171
+        if (_enableAutomaticUrlCopy) {
172
+            setTimeout(this._copyUrlAutomatically, 2000);
173
+        }
174
+    }
175
+
138 176
     /**
139 177
      * Implements React's {@link Component#render()}.
140 178
      *
@@ -177,8 +215,11 @@ class CopyMeetingUrl extends Component<Props, State> {
177 215
  * @returns {Object}
178 216
  */
179 217
 function mapStateToProps(state) {
218
+    const { enableAutomaticUrlCopy } = state['features/base/config'];
219
+
180 220
     return {
181
-        url: getCurrentConferenceUrl(state)
221
+        url: getCurrentConferenceUrl(state),
222
+        _enableAutomaticUrlCopy: enableAutomaticUrlCopy || false
182 223
     };
183 224
 }
184 225
 

Loading…
Cancel
Save