Przeglądaj źródła

fix(livestreaming): show separate message for live streaming not enabled (#3063)

j8
virtuacoplenny 7 lat temu
rodzic
commit
ead62a5dde
No account linked to committer's email address

+ 1
- 0
lang/main.json Wyświetl plik

416
         "enterStreamKey": "Enter your YouTube live stream key here.",
416
         "enterStreamKey": "Enter your YouTube live stream key here.",
417
         "error": "Live Streaming failed. Please try again.",
417
         "error": "Live Streaming failed. Please try again.",
418
         "errorAPI": "An error occurred while accessing your YouTube broadcasts. Please try logging in again.",
418
         "errorAPI": "An error occurred while accessing your YouTube broadcasts. Please try logging in again.",
419
+        "errorLiveStreamNotEnabled": "Live Streaming is not enabled on __email__. Please enable live streaming or log into an account with live streaming enabled.",
419
         "failedToStart": "Live Streaming failed to start",
420
         "failedToStart": "Live Streaming failed to start",
420
         "off": "Live Streaming stopped",
421
         "off": "Live Streaming stopped",
421
         "on": "Live Streaming",
422
         "on": "Live Streaming",

+ 43
- 1
react/features/recording/components/LiveStream/StartLiveStreamDialog.web.js Wyświetl plik

85
      */
85
      */
86
     broadcasts: ?Array<Object>,
86
     broadcasts: ?Array<Object>,
87
 
87
 
88
+    /**
89
+     * The error type, as provided by Google, for the most recent error
90
+     * encountered by the Google API.
91
+     */
92
+    errorType: ?string,
93
+
88
     /**
94
     /**
89
      * The current state of interactions with the Google API. Determines what
95
      * The current state of interactions with the Google API. Determines what
90
      * Google related UI should display.
96
      * Google related UI should display.
129
 
135
 
130
         this.state = {
136
         this.state = {
131
             broadcasts: undefined,
137
             broadcasts: undefined,
138
+            errorType: undefined,
132
             googleAPIState: GOOGLE_API_STATES.NEEDS_LOADING,
139
             googleAPIState: GOOGLE_API_STATES.NEEDS_LOADING,
133
             googleProfileEmail: '',
140
             googleProfileEmail: '',
134
             selectedBoundStreamID: undefined,
141
             selectedBoundStreamID: undefined,
293
                 // Google api. Do not error if the login in canceled.
300
                 // Google api. Do not error if the login in canceled.
294
                 if (response && response.result) {
301
                 if (response && response.result) {
295
                     this._setStateIfMounted({
302
                     this._setStateIfMounted({
303
+                        errorType: this._parseErrorFromResponse(response),
296
                         googleAPIState: GOOGLE_API_STATES.ERROR
304
                         googleAPIState: GOOGLE_API_STATES.ERROR
297
                     });
305
                     });
298
                 }
306
                 }
427
         return Object.values(parsedBroadcasts);
435
         return Object.values(parsedBroadcasts);
428
     }
436
     }
429
 
437
 
438
+    /**
439
+     * Searches in a Google API error response for the error type.
440
+     *
441
+     * @param {Object} response - The Google API response that may contain an
442
+     * error.
443
+     * @private
444
+     * @returns {string|null}
445
+     */
446
+    _parseErrorFromResponse(response) {
447
+        const result = response.result;
448
+        const error = result.error;
449
+        const errors = error && error.errors;
450
+        const firstError = errors && errors[0];
451
+
452
+        return (firstError && firstError.reason) || null;
453
+    }
454
+
430
     /**
455
     /**
431
      * Renders a React Element for authenticating with the Google web client.
456
      * Renders a React Element for authenticating with the Google web client.
432
      *
457
      *
485
                     onClick = { this._onRequestGoogleSignIn }
510
                     onClick = { this._onRequestGoogleSignIn }
486
                     text = { t('liveStreaming.signIn') } />
511
                     text = { t('liveStreaming.signIn') } />
487
             );
512
             );
488
-            helpText = t('liveStreaming.errorAPI');
513
+            helpText = this._getGoogleErrorMessageToDisplay();
489
 
514
 
490
             break;
515
             break;
491
 
516
 
512
         );
537
         );
513
     }
538
     }
514
 
539
 
540
+    /**
541
+     * Returns the error message to display for the current error state.
542
+     *
543
+     * @private
544
+     * @returns {string} The error message to display.
545
+     */
546
+    _getGoogleErrorMessageToDisplay() {
547
+        switch (this.state.errorType) {
548
+        case 'liveStreamingNotEnabled':
549
+            return this.props.t(
550
+                'liveStreaming.errorLiveStreamNotEnabled',
551
+                { email: this.state.googleProfileEmail });
552
+        default:
553
+            return this.props.t('liveStreaming.errorAPI');
554
+        }
555
+    }
556
+
515
     /**
557
     /**
516
      * Updates the internal state if the component is still mounted. This is a
558
      * Updates the internal state if the component is still mounted. This is a
517
      * workaround for all the state setting that occurs after ajax.
559
      * workaround for all the state setting that occurs after ajax.

Ładowanie…
Anuluj
Zapisz