Quellcode durchsuchen

Add dial-in link to no audio notification (#5026)

* Add dial-in link to no audio notification

* refactor react link component

* fix tests
master
Andrei Gavrilescu vor 5 Jahren
Ursprung
Commit
ed5351d250
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 4
- 2
lang/main.json Datei anzeigen

@@ -635,8 +635,10 @@
635 635
         "moreActions": "More actions",
636 636
         "mute": "Mute / Unmute",
637 637
         "noAudioSignalTitle": "There is no input coming from your mic!",
638
-        "noAudioSignalDesc": "If you did not purposely mute it from system settings or hardware, consider changing the device.",
639
-        "noAudioSignalDescSuggestion": "If you did not purposely mute it from system settings or hardware, consider using the following device:",
638
+        "noAudioSignalDesc": "If you did not purposely mute it from system settings or hardware, consider switching the device.",
639
+        "noAudioSignalDescSuggestion": "If you did not purposely mute it from system settings or hardware, consider switching to the suggested device.",
640
+        "noAudioSignalDialInDesc": "You can also dial-in using:",
641
+        "noAudioSignalDialInLinkDesc" : "Dial-in numbers",
640 642
         "noisyAudioInputTitle": "Your microphone appears to be noisy!",
641 643
         "noisyAudioInputDesc": "Jitsi has detected noise coming from your microphone, please consider muting or changing the device.",
642 644
         "openChat": "Open chat",

+ 4
- 21
react/features/invite/components/info-dialog/web/InfoDialog.js Datei anzeigen

@@ -17,7 +17,8 @@ import {
17 17
 import {
18 18
     _decodeRoomURI,
19 19
     _getDefaultPhoneNumber,
20
-    getDialInfoPageURL
20
+    getDialInfoPageURL,
21
+    shouldDisplayDialIn
21 22
 } from '../../../functions';
22 23
 import logger from '../../../logger';
23 24
 import DialInNumber from './DialInNumber';
@@ -316,7 +317,6 @@ class InfoDialog extends Component<Props, State> {
316 317
      */
317 318
     _getTextToCopy() {
318 319
         const { _localParticipant, liveStreamViewURL, t } = this.props;
319
-        const shouldDisplayDialIn = this._shouldDisplayDialIn();
320 320
         const _inviteURL = _decodeRoomURI(this.props._inviteURL);
321 321
 
322 322
         let invite = _localParticipant && _localParticipant.name
@@ -335,7 +335,7 @@ class InfoDialog extends Component<Props, State> {
335 335
             invite = `${invite}\n${liveStream}`;
336 336
         }
337 337
 
338
-        if (shouldDisplayDialIn) {
338
+        if (shouldDisplayDialIn(this.props.dialIn)) {
339 339
             const dial = t('info.invitePhone', {
340 340
                 number: this.state.phoneNumber,
341 341
                 conferenceID: this.props.dialIn.conferenceID
@@ -480,7 +480,7 @@ class InfoDialog extends Component<Props, State> {
480 480
      * @returns {null|ReactElement}
481 481
      */
482 482
     _renderDialInDisplay() {
483
-        if (!this._shouldDisplayDialIn()) {
483
+        if (!shouldDisplayDialIn(this.props.dialIn)) {
484 484
             return null;
485 485
         }
486 486
 
@@ -571,23 +571,6 @@ class InfoDialog extends Component<Props, State> {
571 571
         );
572 572
     }
573 573
 
574
-    /**
575
-     * Returns whether or not dial-in related UI should be displayed.
576
-     *
577
-     * @private
578
-     * @returns {boolean}
579
-     */
580
-    _shouldDisplayDialIn() {
581
-        const { conferenceID, numbers, numbersEnabled } = this.props.dialIn;
582
-        const { phoneNumber } = this.state;
583
-
584
-        return Boolean(
585
-            conferenceID
586
-            && numbers
587
-            && numbersEnabled
588
-            && phoneNumber);
589
-    }
590
-
591 574
     _setCopyElement: () => void;
592 575
 
593 576
     /**

+ 22
- 1
react/features/invite/functions.js Datei anzeigen

@@ -524,6 +524,23 @@ export function getDialInfoPageURLForURIString(
524 524
     return `${protocol}//${host}${contextRoot}static/dialInInfo.html?room=${room}`;
525 525
 }
526 526
 
527
+/**
528
+ * Returns whether or not dial-in related UI should be displayed.
529
+ *
530
+ * @param {Object} dialIn - Dial in information.
531
+ * @returns {boolean}
532
+ */
533
+export function shouldDisplayDialIn(dialIn: Object) {
534
+    const { conferenceID, numbers, numbersEnabled } = dialIn;
535
+    const phoneNumber = _getDefaultPhoneNumber(numbers);
536
+
537
+    return Boolean(
538
+            conferenceID
539
+            && numbers
540
+            && numbersEnabled
541
+            && phoneNumber);
542
+}
543
+
527 544
 /**
528 545
  * Sets the internal state of which dial-in number to display.
529 546
  *
@@ -533,7 +550,11 @@ export function getDialInfoPageURLForURIString(
533 550
  * @returns {string|null}
534 551
  */
535 552
 export function _getDefaultPhoneNumber(
536
-        dialInNumbers: Object): ?string {
553
+        dialInNumbers: ?Object): ?string {
554
+
555
+    if (!dialInNumbers) {
556
+        return null;
557
+    }
537 558
 
538 559
     if (Array.isArray(dialInNumbers)) {
539 560
         // new syntax follows

+ 95
- 0
react/features/no-audio-signal/components/DialInLink.js Datei anzeigen

@@ -0,0 +1,95 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+
5
+import { connect } from '../../base/redux';
6
+import { translate } from '../../base/i18n';
7
+import { getDialInfoPageURL, shouldDisplayDialIn } from '../../invite';
8
+
9
+/**
10
+ * The type of the React {@code Component} props of {@link DialInLink}.
11
+ */
12
+type Props = {
13
+
14
+    /**
15
+     * The name of the current conference.
16
+     */
17
+    _room: string,
18
+
19
+    /**
20
+     * The current location url of the conference.
21
+     */
22
+    _locationURL: string,
23
+
24
+
25
+    /**
26
+     * The redux state representing the dial-in numbers feature.
27
+     */
28
+    _dialIn: Object,
29
+
30
+    /**
31
+     * Invoked to obtain translated strings.
32
+     */
33
+    t: Function
34
+};
35
+
36
+/**
37
+ * React {@code Component} responsible for displaying a telephone number and
38
+ * conference ID for dialing into a conference.
39
+ *
40
+ * @extends Component
41
+ */
42
+class DialInLink extends Component<Props> {
43
+    /**
44
+     * Implements React's {@link Component#render()}.
45
+     *
46
+     * @inheritdoc
47
+     * @returns {ReactElement}
48
+     */
49
+    render() {
50
+        const { _room, _locationURL, _dialIn, t } = this.props;
51
+
52
+        if (!shouldDisplayDialIn(_dialIn)) {
53
+            return null;
54
+        }
55
+
56
+        return (
57
+            <div>{t('toolbar.noAudioSignalDialInDesc')}&nbsp;
58
+                <a
59
+                    href = {
60
+                        getDialInfoPageURL(
61
+                            _room,
62
+                            _locationURL
63
+                        )
64
+                    }
65
+                    rel = 'noopener noreferrer'
66
+                    target = '_blank'>
67
+                    {t('toolbar.noAudioSignalDialInLinkDesc')}
68
+                </a>
69
+            </div>
70
+        );
71
+    }
72
+}
73
+
74
+/**
75
+ * Maps (parts of) the Redux state to the associated props for the
76
+ * {@code DialInLink} component.
77
+ *
78
+ * @param {Object} state - The Redux state.
79
+ * @private
80
+ * @returns {{
81
+    *     _room: string,
82
+    *     _locationURL: string,
83
+    *     _dialIn: Object,
84
+    * }}
85
+    */
86
+function _mapStateToProps(state) {
87
+
88
+    return {
89
+        _room: state['features/base/conference'].room,
90
+        _locationURL: state['features/base/connection'].locationURL,
91
+        _dialIn: state['features/invite']
92
+    };
93
+}
94
+
95
+export default translate(connect(_mapStateToProps)(DialInLink));

+ 5
- 1
react/features/no-audio-signal/middleware.js Datei anzeigen

@@ -1,5 +1,7 @@
1 1
 // @flow
2 2
 
3
+import React from 'react';
4
+
3 5
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
4 6
 import { CONFERENCE_JOINED } from '../base/conference';
5 7
 import {
@@ -13,6 +15,7 @@ import { playSound, registerSound, unregisterSound } from '../base/sounds';
13 15
 import { hideNotification, showNotification } from '../notifications';
14 16
 
15 17
 import { setNoAudioSignalNotificationUid } from './actions';
18
+import DialInLink from './components/DialInLink';
16 19
 import { NO_AUDIO_SIGNAL_SOUND_ID } from './constants';
17 20
 import { NO_AUDIO_SIGNAL_SOUND_FILE } from './sounds';
18 21
 
@@ -91,7 +94,7 @@ async function _handleNoAudioSignalNotification({ dispatch, getState }, action)
91 94
             // at the point of the implementation the showNotification function only supports doing that for
92 95
             // the description.
93 96
             // TODO Add support for arguments to showNotification title and customAction strings.
94
-            customActionNameKey = `Use ${formatDeviceLabel(activeDevice.deviceLabel)}`;
97
+            customActionNameKey = `Switch to ${formatDeviceLabel(activeDevice.deviceLabel)}`;
95 98
             customActionHandler = () => {
96 99
                 // Select device callback
97 100
                 dispatch(
@@ -107,6 +110,7 @@ async function _handleNoAudioSignalNotification({ dispatch, getState }, action)
107 110
 
108 111
         const notification = showNotification({
109 112
             titleKey: 'toolbar.noAudioSignalTitle',
113
+            description: <DialInLink />,
110 114
             descriptionKey,
111 115
             customActionNameKey,
112 116
             customActionHandler

Laden…
Abbrechen
Speichern