|
@@ -3,14 +3,20 @@
|
3
|
3
|
import { getCurrentConference } from '../base/conference';
|
4
|
4
|
import {
|
5
|
5
|
PARTICIPANT_JOINED,
|
|
6
|
+ PARTICIPANT_LEFT,
|
|
7
|
+ getParticipantById,
|
6
|
8
|
getParticipantDisplayName
|
7
|
9
|
} from '../base/participants';
|
8
|
10
|
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
|
9
|
11
|
|
10
|
12
|
import {
|
11
|
13
|
clearNotifications,
|
|
14
|
+ showNotification,
|
12
|
15
|
showParticipantJoinedNotification
|
13
|
16
|
} from './actions';
|
|
17
|
+import { NOTIFICATION_TIMEOUT } from './constants';
|
|
18
|
+
|
|
19
|
+declare var interfaceConfig: Object;
|
14
|
20
|
|
15
|
21
|
/**
|
16
|
22
|
* Middleware that captures actions to display notifications.
|
|
@@ -19,10 +25,10 @@ import {
|
19
|
25
|
* @returns {Function}
|
20
|
26
|
*/
|
21
|
27
|
MiddlewareRegistry.register(store => next => action => {
|
22
|
|
- const result = next(action);
|
23
|
|
-
|
24
|
28
|
switch (action.type) {
|
25
|
29
|
case PARTICIPANT_JOINED: {
|
|
30
|
+ const result = next(action);
|
|
31
|
+
|
26
|
32
|
const { participant: p } = action;
|
27
|
33
|
|
28
|
34
|
if (!p.local) {
|
|
@@ -30,10 +36,31 @@ MiddlewareRegistry.register(store => next => action => {
|
30
|
36
|
getParticipantDisplayName(store.getState, p.id)
|
31
|
37
|
));
|
32
|
38
|
}
|
|
39
|
+
|
|
40
|
+ return result;
|
|
41
|
+ }
|
|
42
|
+ case PARTICIPANT_LEFT: {
|
|
43
|
+ const participant = getParticipantById(
|
|
44
|
+ store.getState(),
|
|
45
|
+ action.participant.id
|
|
46
|
+ );
|
|
47
|
+
|
|
48
|
+ if (typeof interfaceConfig === 'object'
|
|
49
|
+ && participant
|
|
50
|
+ && !participant.local) {
|
|
51
|
+ store.dispatch(showNotification({
|
|
52
|
+ descriptionKey: 'notify.disconnected',
|
|
53
|
+ titleKey: 'notify.somebody',
|
|
54
|
+ title: participant.name
|
|
55
|
+ },
|
|
56
|
+ NOTIFICATION_TIMEOUT));
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ return next(action);
|
33
|
60
|
}
|
34
|
61
|
}
|
35
|
62
|
|
36
|
|
- return result;
|
|
63
|
+ return next(action);
|
37
|
64
|
});
|
38
|
65
|
|
39
|
66
|
/**
|