Browse Source

feat: Only show more numbers link if multiple numbers are available (#8702)

* Only show more numbers link if multiple numbers are available

* Fixed some linter errors

* Try to make flow happy

* Fixed another linter error

* Another try to make eslint happy

* Silence eslint
master
Steffen Kolmer 4 years ago
parent
commit
899968d3a9
No account linked to committer's email address

+ 19
- 9
react/features/invite/components/add-people-dialog/web/DialInSection.js View File

@@ -4,22 +4,28 @@ import React from 'react';
4 4
 
5 5
 import { translate } from '../../../../base/i18n';
6 6
 import { connect } from '../../../../base/redux';
7
-import { getDialInfoPageURL } from '../../../functions';
7
+import { getDialInfoPageURL, hasMultipleNumbers } from '../../../functions';
8 8
 
9 9
 import DialInNumber from './DialInNumber';
10 10
 
11 11
 type Props = {
12 12
 
13 13
     /**
14
-     * The object representing the dialIn feature.
14
+     * The numberic identifier for the current conference, used after dialing a
15
+     * the number to join the conference.
15 16
      */
16
-    _dialIn: Object,
17
+    _conferenceID: number,
17 18
 
18 19
     /**
19 20
      * The url of the page containing the dial-in numbers list.
20 21
      */
21 22
     _dialInfoPageUrl: string,
22 23
 
24
+    /**
25
+     * If multiple dial-in numbers are available
26
+     */
27
+    _hasMultipleNumbers: boolean;
28
+
23 29
     /**
24 30
      * The phone number to dial to begin the process of dialing into a
25 31
      * conference.
@@ -41,23 +47,24 @@ type Props = {
41 47
  * @returns {null|ReactElement}
42 48
  */
43 49
 function DialInSection({
44
-    _dialIn,
50
+    _conferenceID,
45 51
     _dialInfoPageUrl,
52
+    _hasMultipleNumbers,
46 53
     phoneNumber,
47 54
     t
48 55
 }: Props) {
49 56
     return (
50 57
         <div className = 'invite-more-dialog dial-in-display'>
51 58
             <DialInNumber
52
-                conferenceID = { _dialIn.conferenceID }
59
+                conferenceID = { _conferenceID }
53 60
                 phoneNumber = { phoneNumber } />
54
-            <a
61
+            {_hasMultipleNumbers ? <a
55 62
                 className = 'more-numbers'
56 63
                 href = { _dialInfoPageUrl }
57 64
                 rel = 'noopener noreferrer'
58 65
                 target = '_blank'>
59 66
                 { t('info.moreNumbers') }
60
-            </a>
67
+            </a> : null}
61 68
         </div>
62 69
     );
63 70
 }
@@ -72,9 +79,12 @@ function DialInSection({
72 79
  * @returns {Props}
73 80
  */
74 81
 function _mapStateToProps(state) {
82
+    const dialIn = state['features/invite'];
83
+
75 84
     return {
76
-        _dialIn: state['features/invite'],
77
-        _dialInfoPageUrl: getDialInfoPageURL(state)
85
+        _conferenceID: dialIn.conferenceID,
86
+        _dialInfoPageUrl: getDialInfoPageURL(state),
87
+        _hasMultipleNumbers: hasMultipleNumbers(dialIn.numbers)
78 88
     };
79 89
 }
80 90
 

+ 25
- 0
react/features/invite/functions.js View File

@@ -588,6 +588,31 @@ export function shouldDisplayDialIn(dialIn: Object) {
588 588
             && phoneNumber);
589 589
 }
590 590
 
591
+/**
592
+ * Returns if multiple dial-in numbers are available.
593
+ *
594
+ * @param {Array<string>|Object} dialInNumbers - The array or object of
595
+ * numbers to check.
596
+ * @private
597
+ * @returns {boolean}
598
+ */
599
+export function hasMultipleNumbers(dialInNumbers: ?Object) {
600
+    if (!dialInNumbers) {
601
+        return false;
602
+    }
603
+
604
+    if (Array.isArray(dialInNumbers)) {
605
+        return dialInNumbers.length > 1;
606
+    }
607
+
608
+    // deprecated and will be removed
609
+    const { numbers } = dialInNumbers;
610
+
611
+    // eslint-disable-next-line no-confusing-arrow
612
+    return Boolean(numbers && Object.values(numbers).map(a => Array.isArray(a) ? a.length : 0)
613
+        .reduce((a, b) => a + b) > 1);
614
+}
615
+
591 616
 /**
592 617
  * Sets the internal state of which dial-in number to display.
593 618
  *

Loading…
Cancel
Save