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