소스 검색

flow(AbstractAudio): specific function types

master
paweldomas 7 년 전
부모
커밋
4dbcaf851f
4개의 변경된 파일39개의 추가작업 그리고 32개의 파일을 삭제
  1. 17
    10
      react/features/base/media/components/AbstractAudio.js
  2. 1
    3
      react/features/chat/constants.js
  3. 20
    19
      react/features/chat/middleware.js
  4. 1
    0
      react/features/chat/sounds.web.js

+ 17
- 10
react/features/base/media/components/AbstractAudio.js 파일 보기

@@ -7,10 +7,10 @@ import { Component } from 'react';
7 7
  * playback.
8 8
  */
9 9
 export type AudioElement = {
10
-    pause: Function,
11
-    play: Function,
12
-    setSinkId: ?Function
13
-}
10
+    pause: () => void,
11
+    play: () => void,
12
+    setSinkId?: string => void
13
+};
14 14
 
15 15
 /**
16 16
  * {@code AbstractAudio} component's property types.
@@ -21,7 +21,7 @@ type Props = {
21 21
      * A callback which will be called with {@code AbstractAudio} instance once
22 22
      * the audio element is loaded.
23 23
      */
24
-    setRef: ?Function,
24
+    setRef?: ?AudioElement => void,
25 25
 
26 26
     /**
27 27
      * The URL of a media resource to use in the element.
@@ -59,27 +59,31 @@ export default class AbstractAudio extends Component<Props> {
59 59
         this.setAudioElementImpl = this.setAudioElementImpl.bind(this);
60 60
     }
61 61
 
62
+    pause: () => void;
63
+
62 64
     /**
63 65
      * Attempts to pause the playback of the media.
64 66
      *
65 67
      * @public
66 68
      * @returns {void}
67 69
      */
68
-    pause() {
70
+    pause(): void {
69 71
         this._audioElementImpl && this._audioElementImpl.pause();
70 72
     }
71 73
 
74
+    play: () => void;
75
+
72 76
     /**
73 77
      * Attempts to being the playback of the media.
74 78
      *
75 79
      * @public
76 80
      * @returns {void}
77 81
      */
78
-    play() {
82
+    play(): void {
79 83
         this._audioElementImpl && this._audioElementImpl.play();
80 84
     }
81 85
 
82
-    setAudioElementImpl: (?AudioElement) => void;
86
+    setAudioElementImpl: ?AudioElement => void;
83 87
 
84 88
     /**
85 89
      * Set the (reference to the) {@link AudioElement} object which implements
@@ -90,15 +94,18 @@ export default class AbstractAudio extends Component<Props> {
90 94
      * @protected
91 95
      * @returns {void}
92 96
      */
93
-    setAudioElementImpl(element: ?AudioElement) {
97
+    setAudioElementImpl(element: ?AudioElement): void {
94 98
         this._audioElementImpl = element;
95 99
 
96 100
         // setRef
97 101
         const { setRef } = this.props;
98 102
 
103
+        // $FlowFixMe
99 104
         typeof setRef === 'function' && setRef(element ? this : null);
100 105
     }
101 106
 
107
+    setSinkId: string => void;
108
+
102 109
     /**
103 110
      * Sets the sink ID (output device ID) on the underlying audio element.
104 111
      * NOTE: Currently, implemented only on Web.
@@ -106,7 +113,7 @@ export default class AbstractAudio extends Component<Props> {
106 113
      * @param {string} sinkId - The sink ID (output device ID).
107 114
      * @returns {void}
108 115
      */
109
-    setSinkId(sinkId: String) {
116
+    setSinkId(sinkId: string): void {
110 117
         this._audioElementImpl
111 118
             && typeof this._audioElementImpl.setSinkId === 'function'
112 119
             && this._audioElementImpl.setSinkId(sinkId);

+ 1
- 3
react/features/chat/constants.js 파일 보기

@@ -1,9 +1,7 @@
1
-/* eslint-disable no-unused-vars */
2
-import { playAudio } from '../base/media';
3
-
4 1
 /**
5 2
  * The audio ID of the audio element for which the {@link playAudio} action is
6 3
  * triggered when new chat message is received.
4
+ *
7 5
  * @type {string}
8 6
  */
9 7
 export const INCOMING_MSG_SOUND_ID = 'INCOMING_MSG_SOUND';

+ 20
- 19
react/features/chat/middleware.js 파일 보기

@@ -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
 }

+ 1
- 0
react/features/chat/sounds.web.js 파일 보기

@@ -1,5 +1,6 @@
1 1
 /**
2 2
  * The audio source for the incoming chat message sound.
3
+ *
3 4
  * @type {string}
4 5
  */
5 6
 export const INCOMING_MSG_SOUND_SRC = 'sounds/incomingMessage.wav';

Loading…
취소
저장