|
|
@@ -19,22 +19,24 @@ declare var APP: Object;
|
|
19
|
19
|
*/
|
|
20
|
20
|
MiddlewareRegistry.register(store => next => action => {
|
|
21
|
21
|
switch (action.type) {
|
|
22
|
|
- case APP_WILL_MOUNT: {
|
|
23
|
|
- // Register chat msg sound only on web
|
|
24
|
|
- typeof APP !== 'undefined'
|
|
25
|
|
- && store.dispatch(
|
|
|
22
|
+ case APP_WILL_MOUNT:
|
|
|
23
|
+ // Register the chat message sound on Web only because there's no chat
|
|
|
24
|
+ // on mobile.
|
|
|
25
|
+ typeof APP === 'undefined'
|
|
|
26
|
+ || store.dispatch(
|
|
26
|
27
|
registerSound(INCOMING_MSG_SOUND_ID, INCOMING_MSG_SOUND_SRC));
|
|
27
|
28
|
break;
|
|
28
|
|
- }
|
|
29
|
|
- case APP_WILL_UNMOUNT: {
|
|
30
|
|
- // Register chat msg sound only on web
|
|
31
|
|
- typeof APP !== 'undefined'
|
|
32
|
|
- && store.dispatch(unregisterSound(INCOMING_MSG_SOUND_ID));
|
|
|
29
|
+
|
|
|
30
|
+ case APP_WILL_UNMOUNT:
|
|
|
31
|
+ // Unregister the chat message sound on Web because it's registered
|
|
|
32
|
+ // there only.
|
|
|
33
|
+ typeof APP === 'undefined'
|
|
|
34
|
+ || store.dispatch(unregisterSound(INCOMING_MSG_SOUND_ID));
|
|
33
|
35
|
break;
|
|
34
|
|
- }
|
|
|
36
|
+
|
|
35
|
37
|
case CONFERENCE_JOINED:
|
|
36
|
|
- typeof APP !== 'undefined'
|
|
37
|
|
- && _addChatMsgListener(action.conference, store);
|
|
|
38
|
+ typeof APP === 'undefined'
|
|
|
39
|
+ || _addChatMsgListener(action.conference, store);
|
|
38
|
40
|
break;
|
|
39
|
41
|
}
|
|
40
|
42
|
|
|
|
@@ -49,18 +51,17 @@ MiddlewareRegistry.register(store => next => action => {
|
|
49
|
51
|
* new event listener will be registered.
|
|
50
|
52
|
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
|
51
|
53
|
* specified action to the specified store.
|
|
52
|
|
- * @returns {void}
|
|
53
|
54
|
* @private
|
|
|
55
|
+ * @returns {void}
|
|
54
|
56
|
*/
|
|
55
|
57
|
function _addChatMsgListener(conference, { dispatch }) {
|
|
56
|
|
- // XXX Currently there's no need to remove the listener, because
|
|
57
|
|
- // conference instance can not be re-used. Listener will be gone with
|
|
58
|
|
- // the conference instance.
|
|
|
58
|
+ // XXX Currently, there's no need to remove the listener, because the
|
|
|
59
|
+ // JitsiConference instance cannot be reused. Hence, the listener will be
|
|
|
60
|
+ // gone with the JitsiConference instance.
|
|
59
|
61
|
conference.on(
|
|
60
|
62
|
JitsiConferenceEvents.MESSAGE_RECEIVED,
|
|
61
|
63
|
() => {
|
|
62
|
|
- if (!APP.UI.isChatVisible()) {
|
|
63
|
|
- dispatch(playSound(INCOMING_MSG_SOUND_ID));
|
|
64
|
|
- }
|
|
|
64
|
+ APP.UI.isChatVisible()
|
|
|
65
|
+ || dispatch(playSound(INCOMING_MSG_SOUND_ID));
|
|
65
|
66
|
});
|
|
66
|
67
|
}
|