|
@@ -1,3 +1,5 @@
|
|
1
|
+/* @flow */
|
|
2
|
+
|
1
|
3
|
import { ReducerRegistry, setStateProperty } from '../redux';
|
2
|
4
|
|
3
|
5
|
import {
|
|
@@ -9,20 +11,22 @@ import {
|
9
|
11
|
/**
|
10
|
12
|
* Reduces the Redux actions of the feature base/connection.
|
11
|
13
|
*/
|
12
|
|
-ReducerRegistry.register('features/base/connection', (state = {}, action) => {
|
13
|
|
- switch (action.type) {
|
14
|
|
- case CONNECTION_DISCONNECTED:
|
15
|
|
- return _connectionDisconnected(state, action);
|
|
14
|
+ReducerRegistry.register(
|
|
15
|
+ 'features/base/connection',
|
|
16
|
+ (state: Object = {}, action: Object) => {
|
|
17
|
+ switch (action.type) {
|
|
18
|
+ case CONNECTION_DISCONNECTED:
|
|
19
|
+ return _connectionDisconnected(state, action);
|
16
|
20
|
|
17
|
|
- case CONNECTION_ESTABLISHED:
|
18
|
|
- return _connectionEstablished(state, action);
|
|
21
|
+ case CONNECTION_ESTABLISHED:
|
|
22
|
+ return _connectionEstablished(state, action);
|
19
|
23
|
|
20
|
|
- case SET_DOMAIN:
|
21
|
|
- return _setDomain(state, action);
|
22
|
|
- }
|
|
24
|
+ case SET_DOMAIN:
|
|
25
|
+ return _setDomain(state, action);
|
|
26
|
+ }
|
23
|
27
|
|
24
|
|
- return state;
|
25
|
|
-});
|
|
28
|
+ return state;
|
|
29
|
+ });
|
26
|
30
|
|
27
|
31
|
/**
|
28
|
32
|
* Reduces a specific Redux action CONNECTION_DISCONNECTED of the feature
|
|
@@ -34,7 +38,7 @@ ReducerRegistry.register('features/base/connection', (state = {}, action) => {
|
34
|
38
|
* @returns {Object} The new state of the feature base/connection after the
|
35
|
39
|
* reduction of the specified action.
|
36
|
40
|
*/
|
37
|
|
-function _connectionDisconnected(state, action) {
|
|
41
|
+function _connectionDisconnected(state: Object, action: Object) {
|
38
|
42
|
if (state.connection === action.connection) {
|
39
|
43
|
return setStateProperty(state, 'connection', undefined);
|
40
|
44
|
}
|
|
@@ -52,7 +56,7 @@ function _connectionDisconnected(state, action) {
|
52
|
56
|
* @returns {Object} The new state of the feature base/connection after the
|
53
|
57
|
* reduction of the specified action.
|
54
|
58
|
*/
|
55
|
|
-function _connectionEstablished(state, action) {
|
|
59
|
+function _connectionEstablished(state: Object, action: Object) {
|
56
|
60
|
return setStateProperty(state, 'connection', action.connection);
|
57
|
61
|
}
|
58
|
62
|
|
|
@@ -65,7 +69,7 @@ function _connectionEstablished(state, action) {
|
65
|
69
|
* @private
|
66
|
70
|
* @returns {Object}
|
67
|
71
|
*/
|
68
|
|
-function _constructConnectionOptions(domain) {
|
|
72
|
+function _constructConnectionOptions(domain: string) {
|
69
|
73
|
// FIXME The HTTPS scheme for the BOSH URL works with meet.jit.si on both
|
70
|
74
|
// mobile & Web. It also works with beta.meet.jit.si on Web. Unfortunately,
|
71
|
75
|
// it doesn't work with beta.meet.jit.si on mobile. Temporarily, use the
|
|
@@ -89,7 +93,7 @@ function _constructConnectionOptions(domain) {
|
89
|
93
|
boshProtocol || (boshProtocol = 'https:');
|
90
|
94
|
|
91
|
95
|
return {
|
92
|
|
- bosh: `${boshProtocol}//${domain}/http-bind`,
|
|
96
|
+ bosh: `${String(boshProtocol)}//${domain}/http-bind`,
|
93
|
97
|
hosts: {
|
94
|
98
|
domain,
|
95
|
99
|
focus: `focus.${domain}`,
|
|
@@ -107,7 +111,7 @@ function _constructConnectionOptions(domain) {
|
107
|
111
|
* @returns {Object} The new state of the feature base/connection after the
|
108
|
112
|
* reduction of the specified action.
|
109
|
113
|
*/
|
110
|
|
-function _setDomain(state, action) {
|
|
114
|
+function _setDomain(state: Object, action: Object) {
|
111
|
115
|
return {
|
112
|
116
|
...state,
|
113
|
117
|
connectionOptions: {
|