|
@@ -1,10 +1,28 @@
|
1
|
1
|
/* @flow */
|
2
|
2
|
|
3
|
3
|
import { CONFERENCE_WILL_JOIN } from '../base/conference';
|
4
|
|
-import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
|
4
|
+import {
|
|
5
|
+ JitsiConferenceEvents,
|
|
6
|
+ JitsiRecordingConstants
|
|
7
|
+} from '../base/lib-jitsi-meet';
|
5
|
8
|
import { MiddlewareRegistry } from '../base/redux';
|
|
9
|
+import {
|
|
10
|
+ playSound,
|
|
11
|
+ registerSound,
|
|
12
|
+ stopSound,
|
|
13
|
+ unregisterSound
|
|
14
|
+} from '../base/sounds';
|
|
15
|
+
|
|
16
|
+import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
|
6
|
17
|
|
7
|
18
|
import { updateRecordingSessionData } from './actions';
|
|
19
|
+import { RECORDING_SESSION_UPDATED } from './actionTypes';
|
|
20
|
+import { RECORDING_OFF_SOUND_ID, RECORDING_ON_SOUND_ID } from './constants';
|
|
21
|
+import { getSessionById } from './functions';
|
|
22
|
+import {
|
|
23
|
+ RECORDING_OFF_SOUND_FILE,
|
|
24
|
+ RECORDING_ON_SOUND_FILE
|
|
25
|
+} from './sounds';
|
8
|
26
|
|
9
|
27
|
/**
|
10
|
28
|
* The redux middleware to handle the recorder updates in a React way.
|
|
@@ -12,10 +30,34 @@ import { updateRecordingSessionData } from './actions';
|
12
|
30
|
* @param {Store} store - The redux store.
|
13
|
31
|
* @returns {Function}
|
14
|
32
|
*/
|
15
|
|
-MiddlewareRegistry.register(({ dispatch }) => next => action => {
|
|
33
|
+MiddlewareRegistry.register(store => next => action => {
|
|
34
|
+ let oldSessionData;
|
|
35
|
+
|
|
36
|
+ if (action.type === RECORDING_SESSION_UPDATED) {
|
|
37
|
+ oldSessionData
|
|
38
|
+ = getSessionById(store.getState(), action.sessionData.id);
|
|
39
|
+ }
|
|
40
|
+
|
16
|
41
|
const result = next(action);
|
17
|
42
|
|
18
|
43
|
switch (action.type) {
|
|
44
|
+ case APP_WILL_MOUNT:
|
|
45
|
+ store.dispatch(registerSound(
|
|
46
|
+ RECORDING_OFF_SOUND_ID,
|
|
47
|
+ RECORDING_OFF_SOUND_FILE));
|
|
48
|
+
|
|
49
|
+ store.dispatch(registerSound(
|
|
50
|
+ RECORDING_ON_SOUND_ID,
|
|
51
|
+ RECORDING_ON_SOUND_FILE));
|
|
52
|
+
|
|
53
|
+ break;
|
|
54
|
+
|
|
55
|
+ case APP_WILL_UNMOUNT:
|
|
56
|
+ store.dispatch(unregisterSound(RECORDING_OFF_SOUND_ID));
|
|
57
|
+ store.dispatch(unregisterSound(RECORDING_ON_SOUND_ID));
|
|
58
|
+
|
|
59
|
+ break;
|
|
60
|
+
|
19
|
61
|
case CONFERENCE_WILL_JOIN: {
|
20
|
62
|
const { conference } = action;
|
21
|
63
|
|
|
@@ -24,7 +66,7 @@ MiddlewareRegistry.register(({ dispatch }) => next => action => {
|
24
|
66
|
recorderSession => {
|
25
|
67
|
|
26
|
68
|
if (recorderSession && recorderSession.getID()) {
|
27
|
|
- dispatch(
|
|
69
|
+ store.dispatch(
|
28
|
70
|
updateRecordingSessionData(recorderSession));
|
29
|
71
|
|
30
|
72
|
return;
|
|
@@ -33,6 +75,26 @@ MiddlewareRegistry.register(({ dispatch }) => next => action => {
|
33
|
75
|
|
34
|
76
|
break;
|
35
|
77
|
}
|
|
78
|
+
|
|
79
|
+ case RECORDING_SESSION_UPDATED: {
|
|
80
|
+ const updatedSessionData
|
|
81
|
+ = getSessionById(store.getState(), action.sessionData.id);
|
|
82
|
+
|
|
83
|
+ if (updatedSessionData.mode === JitsiRecordingConstants.mode.FILE) {
|
|
84
|
+ const { OFF, ON } = JitsiRecordingConstants.status;
|
|
85
|
+
|
|
86
|
+ if (updatedSessionData.status === ON
|
|
87
|
+ && (!oldSessionData || oldSessionData.status !== ON)) {
|
|
88
|
+ store.dispatch(playSound(RECORDING_ON_SOUND_ID));
|
|
89
|
+ } else if (updatedSessionData.status === OFF
|
|
90
|
+ && (!oldSessionData || oldSessionData.status !== OFF)) {
|
|
91
|
+ store.dispatch(stopSound(RECORDING_ON_SOUND_ID));
|
|
92
|
+ store.dispatch(playSound(RECORDING_OFF_SOUND_ID));
|
|
93
|
+ }
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ break;
|
|
97
|
+ }
|
36
|
98
|
}
|
37
|
99
|
|
38
|
100
|
return result;
|