Browse Source

feat(filmstrip): Don't reorder in small meetings.

master
Hristo Terezov 3 years ago
parent
commit
16bcb1b217

+ 31
- 10
react/features/filmstrip/actions.web.js View File

@@ -4,6 +4,7 @@ import type { Dispatch } from 'redux';
4 4
 import {
5 5
     getLocalParticipant,
6 6
     getParticipantById,
7
+    getRemoteParticipantCount,
7 8
     pinParticipant
8 9
 } from '../base/participants';
9 10
 import { shouldHideSelfView } from '../base/settings/functions.any';
@@ -117,10 +118,14 @@ export function setVerticalViewDimensions() {
117 118
         const disableSelfView = shouldHideSelfView(state);
118 119
         const resizableFilmstrip = isFilmstripResizable(state);
119 120
         const _verticalViewGrid = showGridInVerticalView(state);
121
+        const numberOfRemoteParticipants = getRemoteParticipantCount(state);
120 122
 
121 123
         let gridView = {};
122 124
         let thumbnails = {};
123 125
         let filmstripDimensions = {};
126
+        let hasScroll = false;
127
+        let remoteVideosContainerWidth;
128
+        let remoteVideosContainerHeight;
124 129
 
125 130
         // grid view in the vertical filmstrip
126 131
         if (_verticalViewGrid) {
@@ -143,7 +148,8 @@ export function setVerticalViewDimensions() {
143 148
                 numberOfVisibleTiles
144 149
             });
145 150
             const thumbnailsTotalHeight = rows * (TILE_VERTICAL_MARGIN + height);
146
-            const hasScroll = clientHeight < thumbnailsTotalHeight;
151
+
152
+            hasScroll = clientHeight < thumbnailsTotalHeight;
147 153
             const widthOfFilmstrip = (columns * (TILE_HORIZONTAL_MARGIN + width)) + (hasScroll ? SCROLL_SIZE : 0);
148 154
             const filmstripHeight = Math.min(clientHeight - TILE_VIEW_GRID_VERTICAL_MARGIN, thumbnailsTotalHeight);
149 155
 
@@ -165,6 +171,14 @@ export function setVerticalViewDimensions() {
165 171
             };
166 172
         } else {
167 173
             thumbnails = calculateThumbnailSizeForVerticalView(clientWidth, filmstripWidth.current, resizableFilmstrip);
174
+
175
+            remoteVideosContainerWidth
176
+                = thumbnails?.local?.width + TILE_VERTICAL_CONTAINER_HORIZONTAL_MARGIN + SCROLL_SIZE;
177
+            remoteVideosContainerHeight
178
+                = clientHeight - (disableSelfView ? 0 : thumbnails?.local?.height) - VERTICAL_FILMSTRIP_VERTICAL_MARGIN;
179
+            hasScroll
180
+                = remoteVideosContainerHeight
181
+                    < (thumbnails?.remote.height + TILE_VERTICAL_MARGIN) * numberOfRemoteParticipants;
168 182
         }
169 183
 
170 184
         dispatch({
@@ -172,12 +186,11 @@ export function setVerticalViewDimensions() {
172 186
             dimensions: {
173 187
                 ...thumbnails,
174 188
                 remoteVideosContainer: _verticalViewGrid ? filmstripDimensions : {
175
-                    width: thumbnails?.local?.width
176
-                        + TILE_VERTICAL_CONTAINER_HORIZONTAL_MARGIN + SCROLL_SIZE,
177
-                    height: clientHeight - (disableSelfView ? 0 : thumbnails?.local?.height)
178
-                        - VERTICAL_FILMSTRIP_VERTICAL_MARGIN
189
+                    width: remoteVideosContainerWidth,
190
+                    height: remoteVideosContainerHeight
179 191
                 },
180
-                gridView
192
+                gridView,
193
+                hasScroll
181 194
             }
182 195
         });
183 196
     };
@@ -194,16 +207,24 @@ export function setHorizontalViewDimensions() {
194 207
         const { clientHeight = 0, clientWidth = 0 } = state['features/base/responsive-ui'];
195 208
         const disableSelfView = shouldHideSelfView(state);
196 209
         const thumbnails = calculateThumbnailSizeForHorizontalView(clientHeight);
210
+        const remoteVideosContainerWidth
211
+            = clientWidth - (disableSelfView ? 0 : thumbnails?.local?.width) - HORIZONTAL_FILMSTRIP_MARGIN;
212
+        const remoteVideosContainerHeight
213
+            = thumbnails?.local?.height + TILE_VERTICAL_MARGIN + STAGE_VIEW_THUMBNAIL_VERTICAL_BORDER + SCROLL_SIZE;
214
+        const numberOfRemoteParticipants = getRemoteParticipantCount(state);
215
+        const hasScroll
216
+            = remoteVideosContainerHeight
217
+                < (thumbnails?.remote.width + TILE_HORIZONTAL_MARGIN) * numberOfRemoteParticipants;
197 218
 
198 219
         dispatch({
199 220
             type: SET_HORIZONTAL_VIEW_DIMENSIONS,
200 221
             dimensions: {
201 222
                 ...thumbnails,
202 223
                 remoteVideosContainer: {
203
-                    width: clientWidth - (disableSelfView ? 0 : thumbnails?.local?.width) - HORIZONTAL_FILMSTRIP_MARGIN,
204
-                    height: thumbnails?.local?.height
205
-                        + TILE_VERTICAL_MARGIN + STAGE_VIEW_THUMBNAIL_VERTICAL_BORDER + SCROLL_SIZE
206
-                }
224
+                    width: remoteVideosContainerWidth,
225
+                    height: remoteVideosContainerHeight
226
+                },
227
+                hasScroll
207 228
             }
208 229
         });
209 230
     };

+ 22
- 6
react/features/filmstrip/components/web/Filmstrip.js View File

@@ -88,6 +88,11 @@ type Props = {
88 88
      */
89 89
     _filmstripHeight: number,
90 90
 
91
+    /**
92
+     * Whether or not we have scroll on the filmstrip.
93
+     */
94
+    _hasScroll: boolean,
95
+
91 96
     /**
92 97
      * Whether this is a recorder or not.
93 98
      */
@@ -567,6 +572,7 @@ class Filmstrip extends PureComponent <Props, State> {
567 572
             _currentLayout,
568 573
             _filmstripHeight,
569 574
             _filmstripWidth,
575
+            _hasScroll,
570 576
             _remoteParticipantsLength,
571 577
             _resizableFilmstrip,
572 578
             _rows,
@@ -620,7 +626,7 @@ class Filmstrip extends PureComponent <Props, State> {
620 626
 
621 627
         if (_currentLayout === LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW) {
622 628
             const itemSize = _thumbnailWidth + TILE_HORIZONTAL_MARGIN;
623
-            const isNotOverflowing = (_remoteParticipantsLength * itemSize) <= _filmstripWidth;
629
+            const isNotOverflowing = !_hasScroll;
624 630
 
625 631
             props.itemSize = itemSize;
626 632
 
@@ -632,7 +638,7 @@ class Filmstrip extends PureComponent <Props, State> {
632 638
 
633 639
         } else if (_currentLayout === LAYOUTS.VERTICAL_FILMSTRIP_VIEW) {
634 640
             const itemSize = _thumbnailHeight + TILE_VERTICAL_MARGIN;
635
-            const isNotOverflowing = (_remoteParticipantsLength * itemSize) <= _filmstripHeight;
641
+            const isNotOverflowing = !_hasScroll;
636 642
 
637 643
             if (isNotOverflowing) {
638 644
                 props.className += ' is-not-overflowing';
@@ -768,7 +774,7 @@ function _mapStateToProps(state) {
768 774
         gridDimensions: dimensions = {},
769 775
         filmstripHeight,
770 776
         filmstripWidth,
771
-        hasScroll = false,
777
+        hasScroll: tileViewHasScroll,
772 778
         thumbnailSize: tileViewThumbnailSize
773 779
     } = state['features/filmstrip'].tileViewDimensions;
774 780
     const _currentLayout = getCurrentLayout(state);
@@ -776,6 +782,7 @@ function _mapStateToProps(state) {
776 782
     const _resizableFilmstrip = isFilmstripResizable(state);
777 783
     const _verticalViewGrid = showGridInVerticalView(state);
778 784
     let gridDimensions = dimensions;
785
+    let _hasScroll = false;
779 786
 
780 787
     const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
781 788
     const availableSpace = clientHeight - filmstripHeight;
@@ -806,7 +813,8 @@ function _mapStateToProps(state) {
806 813
 
807 814
     switch (_currentLayout) {
808 815
     case LAYOUTS.TILE_VIEW:
809
-        if (hasScroll) {
816
+        _hasScroll = Boolean(tileViewHasScroll);
817
+        if (_hasScroll) {
810 818
             videosClassName += ' has-scroll';
811 819
         }
812 820
         _thumbnailSize = tileViewThumbnailSize;
@@ -814,8 +822,14 @@ function _mapStateToProps(state) {
814 822
         remoteFilmstripWidth = filmstripWidth;
815 823
         break;
816 824
     case LAYOUTS.VERTICAL_FILMSTRIP_VIEW: {
817
-        const { remote, remoteVideosContainer, gridView } = state['features/filmstrip'].verticalViewDimensions;
825
+        const {
826
+            remote,
827
+            remoteVideosContainer,
828
+            gridView,
829
+            hasScroll
830
+        } = state['features/filmstrip'].verticalViewDimensions;
818 831
 
832
+        _hasScroll = Boolean(hasScroll);
819 833
         remoteFilmstripHeight = remoteVideosContainer?.height - (!_verticalViewGrid && shouldReduceHeight
820 834
             ? TOOLBAR_HEIGHT : 0);
821 835
         remoteFilmstripWidth = remoteVideosContainer?.width;
@@ -833,8 +847,9 @@ function _mapStateToProps(state) {
833 847
         break;
834 848
     }
835 849
     case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW: {
836
-        const { remote, remoteVideosContainer } = state['features/filmstrip'].horizontalViewDimensions;
850
+        const { remote, remoteVideosContainer, hasScroll } = state['features/filmstrip'].horizontalViewDimensions;
837 851
 
852
+        _hasScroll = Boolean(hasScroll);
838 853
         _thumbnailSize = remote;
839 854
         remoteFilmstripHeight = remoteVideosContainer?.height;
840 855
         remoteFilmstripWidth = remoteVideosContainer?.width;
@@ -849,6 +864,7 @@ function _mapStateToProps(state) {
849 864
         _disableSelfView: disableSelfView,
850 865
         _filmstripHeight: remoteFilmstripHeight,
851 866
         _filmstripWidth: remoteFilmstripWidth,
867
+        _hasScroll,
852 868
         _iAmRecorder: Boolean(iAmRecorder),
853 869
         _isFilmstripButtonEnabled: isButtonEnabled('filmstrip', state),
854 870
         _isToolboxVisible: isToolboxVisible(state),

+ 2
- 3
react/features/filmstrip/functions.any.js View File

@@ -1,6 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import { setRemoteParticipants } from './actions';
4
+import { isReorderingEnabled } from './functions';
4 5
 
5 6
 /**
6 7
  * Computes the reorderd list of the remote participants.
@@ -12,11 +13,9 @@ import { setRemoteParticipants } from './actions';
12 13
  */
13 14
 export function updateRemoteParticipants(store: Object, participantId: ?number) {
14 15
     const state = store.getState();
15
-    const { testing = {} } = state['features/base/config'];
16
-    const enableThumbnailReordering = testing.enableThumbnailReordering ?? true;
17 16
     let reorderedParticipants = [];
18 17
 
19
-    if (!enableThumbnailReordering) {
18
+    if (!isReorderingEnabled(state)) {
20 19
         if (participantId) {
21 20
             const { remoteParticipants } = state['features/filmstrip'];
22 21
 

+ 14
- 0
react/features/filmstrip/functions.native.js View File

@@ -88,3 +88,17 @@ export function getColumnCount(stateful: Object | Function) {
88 88
 
89 89
     return Math.min(3, participantCount);
90 90
 }
91
+
92
+/**
93
+ * Returns true if thumbnail reordering is enabled and false otherwise.
94
+ *
95
+ * @param {Object} state - The redux state.
96
+ * @returns {boolean} - True if thumbnail reordering is enabled and false otherwise.
97
+ */
98
+export function isReorderingEnabled(state) {
99
+    const { testing = {} } = state['features/base/config'];
100
+    const enableThumbnailReordering = testing.enableThumbnailReordering ?? true;
101
+
102
+    return enableThumbnailReordering;
103
+}
104
+

+ 41
- 0
react/features/filmstrip/functions.web.js View File

@@ -601,3 +601,44 @@ export function getVerticalViewMaxWidth(state) {
601 601
 
602 602
     return maxWidth;
603 603
 }
604
+
605
+/**
606
+ * Returns true if thumbnail reordering is enabled and false otherwise.
607
+ * Note: The function will return false if all participants are displayed on the screen.
608
+ *
609
+ * @param {Object} state - The redux state.
610
+ * @returns {boolean} - True if thumbnail reordering is enabled and false otherwise.
611
+ */
612
+export function isReorderingEnabled(state) {
613
+    const { testing = {} } = state['features/base/config'];
614
+    const enableThumbnailReordering = testing.enableThumbnailReordering ?? true;
615
+
616
+    return enableThumbnailReordering && isFilmstripScollVisible(state);
617
+}
618
+
619
+/**
620
+ * Returns true if the scroll is displayed and false otherwise.
621
+ *
622
+ * @param {Object} state - The redux state.
623
+ * @returns {boolean} - True if the scroll is displayed and false otherwise.
624
+ */
625
+export function isFilmstripScollVisible(state) {
626
+    const _currentLayout = getCurrentLayout(state);
627
+    let hasScroll = false;
628
+
629
+    switch (_currentLayout) {
630
+    case LAYOUTS.TILE_VIEW:
631
+        ({ hasScroll = false } = state['features/filmstrip'].tileViewDimensions);
632
+        break;
633
+    case LAYOUTS.VERTICAL_FILMSTRIP_VIEW: {
634
+        ({ hasScroll = false } = state['features/filmstrip'].verticalViewDimensions);
635
+        break;
636
+    }
637
+    case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW: {
638
+        ({ hasScroll = false } = state['features/filmstrip'].horizontalViewDimensions);
639
+        break;
640
+    }
641
+    }
642
+
643
+    return hasScroll;
644
+}

+ 8
- 1
react/features/filmstrip/subscriber.web.js View File

@@ -19,7 +19,7 @@ import {
19 19
     ASPECT_RATIO_BREAKPOINT,
20 20
     DISPLAY_DRAWER_THRESHOLD
21 21
 } from './constants';
22
-import { isFilmstripResizable } from './functions.web';
22
+import { isFilmstripResizable, isFilmstripScollVisible, updateRemoteParticipants } from './functions';
23 23
 import './subscriber.any';
24 24
 
25 25
 
@@ -140,3 +140,10 @@ StateListenerRegistry.register(
140 140
     /* listener */(_, store) => {
141 141
         store.dispatch(setVerticalViewDimensions());
142 142
     });
143
+
144
+/**
145
+ * Listens for changes in the filmstrip scroll visibility.
146
+ */
147
+StateListenerRegistry.register(
148
+    /* selector */ state => isFilmstripScollVisible(state),
149
+    /* listener */ (_, store) => updateRemoteParticipants(store));

Loading…
Cancel
Save