ソースを参照

ref(full-screen/middleware): use StateListenerRegistry

Use state listener to simplify the logic and not care about the actions
since the fullscreen flag is calculated from the current conference
state.
master
paweldomas 7年前
コミット
bcb955ea72
1個のファイルの変更12行の追加29行の削除
  1. 12
    29
      react/features/mobile/full-screen/middleware.js

+ 12
- 29
react/features/mobile/full-screen/middleware.js ファイルの表示

4
 import { Immersive } from 'react-native-immersive';
4
 import { Immersive } from 'react-native-immersive';
5
 
5
 
6
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../app';
6
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../../app';
7
-import {
8
-    CONFERENCE_FAILED,
9
-    CONFERENCE_JOINED,
10
-    CONFERENCE_LEFT,
11
-    CONFERENCE_WILL_JOIN,
12
-    SET_AUDIO_ONLY,
13
-    getCurrentConference
14
-} from '../../base/conference';
7
+import { getCurrentConference } from '../../base/conference';
15
 import { Platform } from '../../base/react';
8
 import { Platform } from '../../base/react';
16
-import { MiddlewareRegistry } from '../../base/redux';
9
+import { MiddlewareRegistry, StateListenerRegistry } from '../../base/redux';
17
 
10
 
18
 import { _setImmersiveListener as _setImmersiveListenerA } from './actions';
11
 import { _setImmersiveListener as _setImmersiveListenerA } from './actions';
19
 import { _SET_IMMERSIVE_LISTENER } from './actionTypes';
12
 import { _SET_IMMERSIVE_LISTENER } from './actionTypes';
47
         store.dispatch(_setImmersiveListenerA(undefined));
40
         store.dispatch(_setImmersiveListenerA(undefined));
48
         break;
41
         break;
49
 
42
 
50
-    case CONFERENCE_WILL_JOIN:
51
-    case CONFERENCE_JOINED:
52
-    case SET_AUDIO_ONLY: {
53
-        const result = next(action);
54
-        const { audioOnly } = store.getState()['features/base/conference'];
55
-        const conference = getCurrentConference(store);
56
-
57
-        _setFullScreen(conference ? !audioOnly : false);
58
-
59
-        return result;
60
-    }
61
-
62
-    case CONFERENCE_FAILED:
63
-    case CONFERENCE_LEFT: {
64
-        const result = next(action);
65
-
66
-        _setFullScreen(false);
67
-
68
-        return result;
69
-    }
70
     }
43
     }
71
 
44
 
72
     return next(action);
45
     return next(action);
73
 });
46
 });
74
 
47
 
48
+StateListenerRegistry.register(
49
+    /* selector */ state => {
50
+        const { audioOnly } = state['features/base/conference'];
51
+        const conference = getCurrentConference(state);
52
+
53
+        return conference ? !audioOnly : false;
54
+    },
55
+    /* listener */ fullScreen => _setFullScreen(fullScreen)
56
+);
57
+
75
 /**
58
 /**
76
  * Handler for Immersive mode changes. This will be called when Android's
59
  * Handler for Immersive mode changes. This will be called when Android's
77
  * immersive mode changes. This can happen without us wanting, so re-evaluate if
60
  * immersive mode changes. This can happen without us wanting, so re-evaluate if

読み込み中…
キャンセル
保存