Преглед изворни кода

ref(pinning): remove pinnedId state from VideoLayout

Instead have VideoLayout reach into redux.
j8
Leonard Kim пре 8 година
родитељ
комит
d7bccd0c93
3 измењених фајлова са 36 додато и 38 уклоњено
  1. 2
    8
      modules/FollowMe.js
  2. 33
    23
      modules/UI/videolayout/VideoLayout.js
  3. 1
    7
      react/features/base/conference/middleware.js

+ 2
- 8
modules/FollowMe.js Прегледај датотеку

145
     _setFollowMeInitialState() {
145
     _setFollowMeInitialState() {
146
         this._filmstripToggled.bind(this, this._UI.isFilmstripVisible());
146
         this._filmstripToggled.bind(this, this._UI.isFilmstripVisible());
147
 
147
 
148
-        var pinnedId = VideoLayout.getPinnedId();
149
-        var isPinned = false;
150
-        var smallVideo;
151
-        if (pinnedId) {
152
-            isPinned = true;
153
-            smallVideo = VideoLayout.getSmallVideo(pinnedId);
154
-        }
148
+        const pinnedId = VideoLayout.getPinnedId();
155
 
149
 
156
-        this._nextOnStage(smallVideo.getId(), isPinned);
150
+        this._nextOnStage(pinnedId, Boolean(pinnedId));
157
 
151
 
158
         // check whether shared document is enabled/initialized
152
         // check whether shared document is enabled/initialized
159
         if(this._UI.getSharedDocumentManager())
153
         if(this._UI.getSharedDocumentManager())

+ 33
- 23
modules/UI/videolayout/VideoLayout.js Прегледај датотеку

1
 /* global APP, $, interfaceConfig, JitsiMeetJS  */
1
 /* global APP, $, interfaceConfig, JitsiMeetJS  */
2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
3
 
3
 
4
-import { pinParticipant } from '../../../react/features/base/participants';
4
+import {
5
+    getPinnedParticipant,
6
+    pinParticipant
7
+} from '../../../react/features/base/participants';
5
 
8
 
6
 import Filmstrip from "./Filmstrip";
9
 import Filmstrip from "./Filmstrip";
7
 import UIEvents from "../../../service/UI/UIEvents";
10
 import UIEvents from "../../../service/UI/UIEvents";
22
 
25
 
23
 var eventEmitter = null;
26
 var eventEmitter = null;
24
 
27
 
25
-// TODO Remove this private reference to pinnedId once other components
26
-// interested in its updates are moved to react/redux.
27
-/**
28
- * Currently focused video jid
29
- * @type {String}
30
- */
31
-var pinnedId = null;
32
-
33
 /**
28
 /**
34
  * flipX state of the localVideo
29
  * flipX state of the localVideo
35
  */
30
  */
63
             // let the bridge adjust its lastN set for myjid and store
58
             // let the bridge adjust its lastN set for myjid and store
64
             // the pinned user in the lastNPickupId variable to be
59
             // the pinned user in the lastNPickupId variable to be
65
             // picked up later by the lastN changed event handler.
60
             // picked up later by the lastN changed event handler.
66
-            APP.store.dispatch(pinParticipant(remoteVideo.id));
61
+            this.pinParticipant(remoteVideo.id);
67
         }
62
         }
68
     }
63
     }
69
 }
64
 }
281
             return;
276
             return;
282
         }
277
         }
283
 
278
 
279
+        const pinnedId = this.getPinnedId();
284
         let newId;
280
         let newId;
285
 
281
 
286
         if (pinnedId)
282
         if (pinnedId)
392
     },
388
     },
393
 
389
 
394
     isPinned (id) {
390
     isPinned (id) {
395
-        return (pinnedId) ? (id === pinnedId) : false;
391
+        return id === this.getPinnedId();
396
     },
392
     },
397
 
393
 
398
     getPinnedId () {
394
     getPinnedId () {
399
-        return pinnedId;
395
+        const { id } = getPinnedParticipant(APP.store.getState()) || {};
396
+
397
+        return id || null;
398
+    },
399
+
400
+    /**
401
+     * Updates the desired pinned participant and notifies web UI of the change.
402
+     *
403
+     * @param {string|null} id - The participant id of the participant to be
404
+     * pinned. Pass in null to unpin without pinning another participant.
405
+     * @returns {void}
406
+     */
407
+    pinParticipant(id) {
408
+        APP.store.dispatch(pinParticipant(id));
409
+        APP.UI.emitEvent(UIEvents.PINNED_ENDPOINT, id, Boolean(id));
400
     },
410
     },
401
 
411
 
402
     /**
412
     /**
406
      */
416
      */
407
     handleVideoThumbClicked (id) {
417
     handleVideoThumbClicked (id) {
408
         var smallVideo = VideoLayout.getSmallVideo(id);
418
         var smallVideo = VideoLayout.getSmallVideo(id);
419
+        const pinnedId = this.getPinnedId();
420
+
409
         if(pinnedId) {
421
         if(pinnedId) {
410
             var oldSmallVideo = VideoLayout.getSmallVideo(pinnedId);
422
             var oldSmallVideo = VideoLayout.getSmallVideo(pinnedId);
411
             if (oldSmallVideo && !interfaceConfig.filmStripOnly) {
423
             if (oldSmallVideo && !interfaceConfig.filmStripOnly) {
416
         // Unpin if currently pinned.
428
         // Unpin if currently pinned.
417
         if (pinnedId === id)
429
         if (pinnedId === id)
418
         {
430
         {
419
-            pinnedId = null;
420
-
421
-            APP.store.dispatch(pinParticipant(null));
431
+            this.pinParticipant(null);
422
 
432
 
423
             // Enable the currently set dominant speaker.
433
             // Enable the currently set dominant speaker.
424
             if (currentDominantSpeaker) {
434
             if (currentDominantSpeaker) {
436
             return;
446
             return;
437
         }
447
         }
438
 
448
 
439
-        // Lock new video
440
-        pinnedId = id;
441
-
442
         // Update focused/pinned interface.
449
         // Update focused/pinned interface.
443
         if (id) {
450
         if (id) {
444
             if (smallVideo && !interfaceConfig.filmStripOnly) {
451
             if (smallVideo && !interfaceConfig.filmStripOnly) {
445
                 smallVideo.focus(true);
452
                 smallVideo.focus(true);
446
-                APP.store.dispatch(pinParticipant(id));
453
+                this.pinParticipant(id);
447
             }
454
             }
448
         }
455
         }
449
 
456
 
530
      * @returns {void}
537
      * @returns {void}
531
      */
538
      */
532
     _maybePlaceParticipantOnLargeVideo(resourceJid) {
539
     _maybePlaceParticipantOnLargeVideo(resourceJid) {
540
+        const pinnedId = this.getPinnedId();
541
+
533
         if ((!pinnedId &&
542
         if ((!pinnedId &&
534
             !currentDominantSpeaker &&
543
             !currentDominantSpeaker &&
535
             this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE)) ||
544
             this.isLargeContainerTypeVisible(VIDEO_CONTAINER_TYPE)) ||
727
         // Update the large video if the video source is already available,
736
         // Update the large video if the video source is already available,
728
         // otherwise wait for the "videoactive.jingle" event.
737
         // otherwise wait for the "videoactive.jingle" event.
729
         // FIXME: there is no "videoactive.jingle" event.
738
         // FIXME: there is no "videoactive.jingle" event.
730
-        if (!interfaceConfig.filmStripOnly && !pinnedId
739
+        if (!interfaceConfig.filmStripOnly && !this.getPinnedId()
731
             && remoteVideo.hasVideoStarted()
740
             && remoteVideo.hasVideoStarted()
732
             && !this.getCurrentlyOnLargeContainer().stayOnStage()) {
741
             && !this.getCurrentlyOnLargeContainer().stayOnStage()) {
733
             this.updateLargeVideo(id);
742
             this.updateLargeVideo(id);
819
 
828
 
820
     removeParticipantContainer (id) {
829
     removeParticipantContainer (id) {
821
         // Unlock large video
830
         // Unlock large video
822
-        if (pinnedId === id) {
831
+        if (this.getPinnedId() === id) {
823
             logger.info("Focused video owner has left the conference");
832
             logger.info("Focused video owner has left the conference");
824
-            pinnedId = null;
825
-            APP.store.dispatch(pinParticipant(null));
833
+            this.pinParticipant(null);
826
         }
834
         }
827
 
835
 
828
         if (currentDominantSpeaker === id) {
836
         if (currentDominantSpeaker === id) {
1072
         // (pinned remote video) use its video type,
1080
         // (pinned remote video) use its video type,
1073
         // if not then use default type - large video
1081
         // if not then use default type - large video
1074
         if (!show) {
1082
         if (!show) {
1083
+            const pinnedId = this.getPinnedId();
1084
+
1075
             if(pinnedId)
1085
             if(pinnedId)
1076
                 containerTypeToShow = this.getRemoteVideoType(pinnedId);
1086
                 containerTypeToShow = this.getRemoteVideoType(pinnedId);
1077
             else
1087
             else

+ 1
- 7
react/features/base/conference/middleware.js Прегледај датотеку

176
     const participantById = getParticipantById(participants, id);
176
     const participantById = getParticipantById(participants, id);
177
     let pin;
177
     let pin;
178
 
178
 
179
-    const shouldEmitToLegacyApp = typeof APP !== 'undefined';
180
-
181
-    if (shouldEmitToLegacyApp) {
179
+    if (typeof APP !== 'undefined') {
182
         const pinnedParticipant = getPinnedParticipant(participants);
180
         const pinnedParticipant = getPinnedParticipant(participants);
183
         const actionName = action.participant.id ? 'pinned' : 'unpinned';
181
         const actionName = action.participant.id ? 'pinned' : 'unpinned';
184
         let videoType;
182
         let videoType;
218
         }
216
         }
219
     }
217
     }
220
 
218
 
221
-    if (shouldEmitToLegacyApp) {
222
-        APP.UI.emitEvent(UIEvents.PINNED_ENDPOINT, id, Boolean(id));
223
-    }
224
-
225
     return next(action);
219
     return next(action);
226
 }
220
 }
227
 
221
 

Loading…
Откажи
Сачувај