|
@@ -0,0 +1,39 @@
|
|
1
|
+import {
|
|
2
|
+ PIN_PARTICIPANT,
|
|
3
|
+ getPinnedParticipant,
|
|
4
|
+ pinParticipant
|
|
5
|
+} from '../base/participants';
|
|
6
|
+import { MiddlewareRegistry } from '../base/redux';
|
|
7
|
+
|
|
8
|
+import { SET_TILE_VIEW } from './actionTypes';
|
|
9
|
+import { setTileView } from './actions';
|
|
10
|
+
|
|
11
|
+/**
|
|
12
|
+ * Middleware which intercepts actions and updates tile view related state.
|
|
13
|
+ *
|
|
14
|
+ * @param {Store} store - The redux store.
|
|
15
|
+ * @returns {Function}
|
|
16
|
+ */
|
|
17
|
+MiddlewareRegistry.register(store => next => action => {
|
|
18
|
+ switch (action.type) {
|
|
19
|
+ case PIN_PARTICIPANT: {
|
|
20
|
+ const isPinning = Boolean(action.participant.id);
|
|
21
|
+ const { tileViewEnabled } = store.getState()['features/video-layout'];
|
|
22
|
+
|
|
23
|
+ if (isPinning && tileViewEnabled) {
|
|
24
|
+ store.dispatch(setTileView(false));
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ break;
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ case SET_TILE_VIEW:
|
|
31
|
+ if (getPinnedParticipant(store.getState()) && action.enabled) {
|
|
32
|
+ store.dispatch(pinParticipant(null));
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ break;
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ return next(action);
|
|
39
|
+});
|