소스 검색

[RN] Add reload overlay in case of connection / conference errors

master
Saúl Ibarra Corretgé 8 년 전
부모
커밋
87a87eebb9

+ 4
- 1
react/features/base/conference/reducer.js 파일 보기

@@ -405,7 +405,10 @@ function _setRoom(state, action) {
405 405
      *
406 406
      * @type {string}
407 407
      */
408
-    return set(state, 'room', room);
408
+    return assign(state, {
409
+        error: undefined,
410
+        room
411
+    });
409 412
 }
410 413
 
411 414
 /**

+ 18
- 1
react/features/base/connection/reducer.js 파일 보기

@@ -1,6 +1,7 @@
1 1
 /* @flow */
2 2
 
3
-import { assign, ReducerRegistry } from '../redux';
3
+import { SET_ROOM } from '../conference';
4
+import { assign, set, ReducerRegistry } from '../redux';
4 5
 import { parseURIString } from '../util';
5 6
 
6 7
 import {
@@ -32,6 +33,9 @@ ReducerRegistry.register(
32 33
 
33 34
         case SET_LOCATION_URL:
34 35
             return _setLocationURL(state, action);
36
+
37
+        case SET_ROOM:
38
+            return _setRoom(state);
35 39
         }
36 40
 
37 41
         return state;
@@ -194,3 +198,16 @@ function _setLocationURL(
194 198
         options: locationURL ? _constructOptions(locationURL) : undefined
195 199
     });
196 200
 }
201
+
202
+/**
203
+ * Reduces a specific redux action {@link SET_ROOM} of the feature
204
+ * base/connection.
205
+ *
206
+ * @param {Object} state - The redux state of the feature base/connection.
207
+ * @private
208
+ * @returns {Object} The new state of the feature base/connection after the
209
+ * reduction of the specified action.
210
+ */
211
+function _setRoom(state: Object) {
212
+    return set(state, 'error', undefined);
213
+}

+ 1
- 1
react/features/base/jwt/components/CalleeInfoContainer.js 파일 보기

@@ -6,7 +6,7 @@ import { connect } from 'react-redux';
6 6
 import CalleeInfo from './CalleeInfo';
7 7
 
8 8
 /**
9
- * The type of the React {@code Component} props of {@link Conference}.
9
+ * The type of the React {@code Component} props of {@code CalleeInfoContainer}.
10 10
  */
11 11
 type Props = {
12 12
 

+ 7
- 3
react/features/overlay/actions.js 파일 보기

@@ -1,3 +1,5 @@
1
+import { appNavigate } from '../app';
2
+import { toURLString } from '../base/util';
1 3
 import { reload, replace } from '../../../modules/util/helpers';
2 4
 
3 5
 import {
@@ -40,11 +42,13 @@ export function _reloadNow() {
40 42
 
41 43
         logger.info(`Reloading the conference using URL: ${locationURL}`);
42 44
 
43
-        // In an iframe reload with the reload() utility because the replace()
44
-        // utility does not work on an iframe.
45
-        if (window.self === window.top) {
45
+        if (navigator.product === 'ReactNative') {
46
+            dispatch(appNavigate(toURLString(locationURL)));
47
+        } else if (window.self === window.top) {
46 48
             replace(locationURL);
47 49
         } else {
50
+            // In an iframe reload with the reload() utility because the
51
+            // replace() utility does not work on an iframe.
48 52
             reload();
49 53
         }
50 54
     };

+ 7
- 4
react/features/overlay/components/AbstractPageReloadOverlay.js 파일 보기

@@ -156,10 +156,13 @@ export default class AbstractPageReloadOverlay extends Component<*, *> {
156 156
         // because the log queue is not flushed before "fabric terminated" is
157 157
         // sent to the backed.
158 158
         // FIXME: We should dispatch action for this.
159
-        APP.conference.logEvent(
160
-            PAGE_RELOAD,
161
-            /* value */ undefined,
162
-            /* label */ this.props.reason);
159
+        if (typeof APP !== 'undefined') {
160
+            APP.conference.logEvent(
161
+                PAGE_RELOAD,
162
+                /* value */ undefined,
163
+                /* label */ this.props.reason);
164
+        }
165
+
163 166
         logger.info(
164 167
             `The conference will be reloaded after ${
165 168
                 this.state.timeoutSeconds} seconds.`);

+ 9
- 3
react/features/overlay/components/OverlayContainer.js 파일 보기

@@ -91,10 +91,16 @@ function _getOverlays(filmstripOnly) {
91 91
         }
92 92
     } else if (!(overlays = _nonFilmstripOnlyOverlays)) {
93 93
         overlays = _nonFilmstripOnlyOverlays = [
94
-            PageReloadOverlay,
95
-            SuspendedOverlay,
96
-            UserMediaPermissionsOverlay
94
+            PageReloadOverlay
97 95
         ];
96
+
97
+        // Mobile only has a PageReloadOverlay.
98
+        if (navigator.product !== 'ReactNative') {
99
+            overlays.push(...[
100
+                SuspendedOverlay,
101
+                UserMediaPermissionsOverlay
102
+            ]);
103
+        }
98 104
     }
99 105
 
100 106
     return overlays;

+ 36
- 0
react/features/overlay/components/OverlayFrame.native.js 파일 보기

@@ -0,0 +1,36 @@
1
+// @flow
2
+
3
+import React, { Component } from 'react';
4
+import { View } from 'react-native';
5
+
6
+import { overlayFrame as styles } from './styles';
7
+
8
+/**
9
+ * The type of the React {@code Component} props of {@code OverlayFrame}.
10
+ */
11
+type Props = {
12
+
13
+    /**
14
+     * The children components to be displayed into the overlay frame.
15
+     */
16
+    children?: React$Node,
17
+};
18
+
19
+/**
20
+ * Implements a React component to act as the frame for overlays.
21
+ */
22
+export default class OverlayFrame extends Component<Props> {
23
+    /**
24
+     * Implements React's {@link Component#render()}.
25
+     *
26
+     * @inheritdoc
27
+     * @returns {React$Element}
28
+     */
29
+    render() {
30
+        return (
31
+            <View style = { styles.container }>
32
+                { this.props.children }
33
+            </View>
34
+        );
35
+    }
36
+}

react/features/overlay/components/OverlayFrame.js → react/features/overlay/components/OverlayFrame.web.js 파일 보기


+ 101
- 0
react/features/overlay/components/PageReloadOverlay.native.js 파일 보기

@@ -0,0 +1,101 @@
1
+import React from 'react';
2
+import { Text, View } from 'react-native';
3
+import { connect } from 'react-redux';
4
+
5
+import { appNavigate } from '../../app';
6
+import { translate } from '../../base/i18n';
7
+import { LoadingIndicator } from '../../base/react';
8
+
9
+import { _reloadNow } from '../actions';
10
+
11
+import AbstractPageReloadOverlay, { abstractMapStateToProps }
12
+    from './AbstractPageReloadOverlay';
13
+import OverlayFrame from './OverlayFrame';
14
+import { pageReloadOverlay as styles } from './styles';
15
+
16
+/**
17
+ * Implements a React Component for page reload overlay. Shown before the
18
+ * conference is reloaded. Shows a warning message and counts down towards the
19
+ * reload.
20
+ */
21
+class PageReloadOverlay extends AbstractPageReloadOverlay {
22
+    /**
23
+     * Initializes a new PageReloadOverlay instance.
24
+     *
25
+     * @param {Object} props - The read-only properties with which the new
26
+     * instance is to be initialized.
27
+     * @public
28
+     */
29
+    constructor(props) {
30
+        super(props);
31
+
32
+        this._onCancel = this._onCancel.bind(this);
33
+        this._onReloadNow = this._onReloadNow.bind(this);
34
+    }
35
+
36
+    /**
37
+     * Handle clicking of the "Cancel" button. It will navigate back to the
38
+     * welcome page.
39
+     *
40
+     * @private
41
+     * @returns {void}
42
+     */
43
+    _onCancel() {
44
+        clearInterval(this._interval);
45
+        this.props.dispatch(appNavigate(undefined));
46
+    }
47
+
48
+    /**
49
+     * Handle clicking on the "Reload Now" button. It will navigate to the same
50
+     * conference URL as before immediately, without waiting for the timer to
51
+     * kick in.
52
+     *
53
+     * @private
54
+     * @returns {void}
55
+     */
56
+    _onReloadNow() {
57
+        clearInterval(this._interval);
58
+        this.props.dispatch(_reloadNow());
59
+    }
60
+
61
+    /**
62
+     * Implements React's {@link Component#render()}.
63
+     *
64
+     * @inheritdoc
65
+     * @returns {ReactElement}
66
+     */
67
+    render() {
68
+        const { t } = this.props;
69
+        const { message, timeLeft, title } = this.state;
70
+
71
+        return (
72
+            <OverlayFrame>
73
+                <View style = { styles.container }>
74
+                    <View style = { styles.loadingIndicator }>
75
+                        <LoadingIndicator />
76
+                    </View>
77
+                    <Text style = { styles.title }>
78
+                        { t(title) }
79
+                    </Text>
80
+                    <Text style = { styles.message }>
81
+                        { t(message, { seconds: timeLeft }) }
82
+                    </Text>
83
+                    <View style = { styles.buttonBox }>
84
+                        <Text
85
+                            onPress = { this._onReloadNow }
86
+                            style = { styles.button } >
87
+                            { t('dialog.rejoinNow') }
88
+                        </Text>
89
+                        <Text
90
+                            onPress = { this._onCancel }
91
+                            style = { styles.button } >
92
+                            { t('dialog.Cancel') }
93
+                        </Text>
94
+                    </View>
95
+                </View>
96
+            </OverlayFrame>
97
+        );
98
+    }
99
+}
100
+
101
+export default translate(connect(abstractMapStateToProps)(PageReloadOverlay));

react/features/overlay/components/PageReloadOverlay.js → react/features/overlay/components/PageReloadOverlay.web.js 파일 보기


+ 91
- 0
react/features/overlay/components/styles.js 파일 보기

@@ -0,0 +1,91 @@
1
+import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';
2
+
3
+/**
4
+ * The default color of text on overlays.
5
+ */
6
+const TEXT_COLOR = ColorPalette.white;
7
+
8
+/**
9
+ * The React {@code Component} styles of {@code OverlayFrame}.
10
+ */
11
+export const overlayFrame = createStyleSheet({
12
+    /**
13
+     * Style for a backdrop overlay covering the screen the the overlay is
14
+     * rendered.
15
+     */
16
+    container: {
17
+        backgroundColor: ColorPalette.red,
18
+        bottom: 0,
19
+        left: 0,
20
+        position: 'absolute',
21
+        right: 0,
22
+        top: 0
23
+    }
24
+});
25
+
26
+/**
27
+ * The React {@code Component} styles of {@code PageReloadOverlay}.
28
+ */
29
+export const pageReloadOverlay = createStyleSheet({
30
+    /**
31
+     * Style for the buttons on {@code PageReloadOverlay}.
32
+     */
33
+    button: {
34
+        color: TEXT_COLOR,
35
+        fontSize: 20,
36
+        marginVertical: BoxModel.margin,
37
+        textAlign: 'center'
38
+    },
39
+
40
+    /**
41
+     * Style for the "box" surrounding the buttons at the bottom of the page.
42
+     */
43
+    buttonBox: {
44
+        bottom: BoxModel.margin,
45
+        left: 0,
46
+        position: 'absolute',
47
+        right: 0
48
+    },
49
+
50
+    /**
51
+     * Style for the container of the {@code PageReloadOVerlay}.
52
+     */
53
+    container: {
54
+        flex: 1,
55
+        marginBottom: BoxModel.margin,
56
+        marginHorizontal: BoxModel.margin,
57
+        marginTop: BoxModel.margin * 3
58
+    },
59
+
60
+    /**
61
+     * Style for the {@code LoadingIndicator}.
62
+     */
63
+    loadingIndicator: {
64
+        alignItems: 'center',
65
+        bottom: 0,
66
+        justifyContent: 'center',
67
+        left: 0,
68
+        position: 'absolute',
69
+        right: 0,
70
+        top: 0
71
+    },
72
+
73
+    /**
74
+     * Style for the descriptive error message.
75
+     */
76
+    message: {
77
+        color: TEXT_COLOR,
78
+        fontSize: 16,
79
+        marginTop: BoxModel.margin,
80
+        textAlign: 'center'
81
+    },
82
+
83
+    /**
84
+     * Style for the error title.
85
+     */
86
+    title: {
87
+        color: TEXT_COLOR,
88
+        fontSize: 24,
89
+        textAlign: 'center'
90
+    }
91
+});

Loading…
취소
저장