|
@@ -11,6 +11,7 @@ import { IReduxState } from '../../../../app/types';
|
11
|
11
|
import { translate } from '../../../i18n/functions';
|
12
|
12
|
import { isFatalJitsiConnectionError } from '../../../lib-jitsi-meet/functions.native';
|
13
|
13
|
import { connect } from '../../../redux/functions';
|
|
14
|
+import { hideDialog } from '../../actions';
|
14
|
15
|
// @ts-ignore
|
15
|
16
|
import logger from '../../logger';
|
16
|
17
|
|
|
@@ -33,10 +34,7 @@ interface IPageReloadDialogProps extends WithTranslation {
|
33
|
34
|
* {@link PageReloadDialog}.
|
34
|
35
|
*/
|
35
|
36
|
interface IPageReloadDialogState {
|
36
|
|
- message: string;
|
37
|
37
|
timeLeft: number;
|
38
|
|
- timeoutSeconds: number;
|
39
|
|
- title: string;
|
40
|
38
|
}
|
41
|
39
|
|
42
|
40
|
/**
|
|
@@ -48,6 +46,7 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
48
|
46
|
|
49
|
47
|
// @ts-ignore
|
50
|
48
|
_interval: IntervalID;
|
|
49
|
+ _timeoutSeconds: number;
|
51
|
50
|
|
52
|
51
|
/**
|
53
|
52
|
* Initializes a new PageReloadOverlay instance.
|
|
@@ -59,27 +58,15 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
59
|
58
|
constructor(props: IPageReloadDialogProps) {
|
60
|
59
|
super(props);
|
61
|
60
|
|
62
|
|
- const timeoutSeconds = 10 + randomInt(0, 20);
|
63
|
|
-
|
64
|
|
- let message, title;
|
65
|
|
-
|
66
|
|
- if (this.props.isNetworkFailure) {
|
67
|
|
- title = 'dialog.conferenceDisconnectTitle';
|
68
|
|
- message = 'dialog.conferenceDisconnectMsg';
|
69
|
|
- } else {
|
70
|
|
- title = 'dialog.conferenceReloadTitle';
|
71
|
|
- message = 'dialog.conferenceReloadMsg';
|
72
|
|
- }
|
|
61
|
+ this._timeoutSeconds = 10 + randomInt(0, 20);
|
73
|
62
|
|
74
|
63
|
this.state = {
|
75
|
|
- message,
|
76
|
|
- timeLeft: timeoutSeconds,
|
77
|
|
- timeoutSeconds,
|
78
|
|
- title
|
|
64
|
+ timeLeft: this._timeoutSeconds
|
79
|
65
|
};
|
80
|
66
|
|
81
|
67
|
this._onCancel = this._onCancel.bind(this);
|
82
|
68
|
this._onReloadNow = this._onReloadNow.bind(this);
|
|
69
|
+ this._onReconnecting = this._onReconnecting.bind(this);
|
83
|
70
|
}
|
84
|
71
|
|
85
|
72
|
/**
|
|
@@ -89,32 +76,14 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
89
|
76
|
* @returns {void}
|
90
|
77
|
*/
|
91
|
78
|
componentDidMount() {
|
92
|
|
- const { dispatch } = this.props;
|
93
|
79
|
const { timeLeft } = this.state;
|
94
|
80
|
|
95
|
81
|
logger.info(
|
96
|
|
- `The conference will be reloaded after ${
|
97
|
|
- this.state.timeoutSeconds} seconds.`);
|
98
|
|
-
|
99
|
|
- this._interval
|
100
|
|
- = setInterval(
|
101
|
|
- () => {
|
102
|
|
- if (timeLeft === 0) {
|
103
|
|
- if (this._interval) {
|
104
|
|
- clearInterval(this._interval);
|
105
|
|
- this._interval = undefined;
|
106
|
|
- }
|
107
|
|
-
|
108
|
|
- dispatch(reloadNow());
|
109
|
|
- } else {
|
110
|
|
- this.setState(prevState => {
|
111
|
|
- return {
|
112
|
|
- timeLeft: prevState.timeLeft - 1
|
113
|
|
- };
|
114
|
|
- });
|
115
|
|
- }
|
116
|
|
- },
|
117
|
|
- 1000);
|
|
82
|
+ `The conference will be reloaded after ${timeLeft} seconds.`
|
|
83
|
+ );
|
|
84
|
+
|
|
85
|
+ this._interval = setInterval(() =>
|
|
86
|
+ this._onReconnecting(), 1000);
|
118
|
87
|
}
|
119
|
88
|
|
120
|
89
|
/**
|
|
@@ -138,12 +107,37 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
138
|
107
|
* @returns {boolean}
|
139
|
108
|
*/
|
140
|
109
|
_onCancel() {
|
|
110
|
+ const { dispatch } = this.props;
|
|
111
|
+
|
141
|
112
|
clearInterval(this._interval);
|
142
|
|
- this.props.dispatch(appNavigate(undefined));
|
|
113
|
+ dispatch(appNavigate(undefined));
|
143
|
114
|
|
144
|
115
|
return true;
|
145
|
116
|
}
|
146
|
117
|
|
|
118
|
+ /**
|
|
119
|
+ * Handles automatic reconnection.
|
|
120
|
+ *
|
|
121
|
+ * @private
|
|
122
|
+ * @returns {void}
|
|
123
|
+ */
|
|
124
|
+ _onReconnecting() {
|
|
125
|
+ const { dispatch } = this.props;
|
|
126
|
+ const { timeLeft } = this.state;
|
|
127
|
+
|
|
128
|
+ if (timeLeft === 0) {
|
|
129
|
+ if (this._interval) {
|
|
130
|
+ dispatch(hideDialog());
|
|
131
|
+ this._onReloadNow();
|
|
132
|
+ this._interval = undefined;
|
|
133
|
+ }
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ this.setState({
|
|
137
|
+ timeLeft: timeLeft - 1
|
|
138
|
+ });
|
|
139
|
+ }
|
|
140
|
+
|
147
|
141
|
/**
|
148
|
142
|
* Handle clicking on the "Reload Now" button. It will navigate to the same
|
149
|
143
|
* conference URL as before immediately, without waiting for the timer to
|
|
@@ -153,8 +147,10 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
153
|
147
|
* @returns {boolean}
|
154
|
148
|
*/
|
155
|
149
|
_onReloadNow() {
|
|
150
|
+ const { dispatch } = this.props;
|
|
151
|
+
|
156
|
152
|
clearInterval(this._interval);
|
157
|
|
- this.props.dispatch(reloadNow());
|
|
153
|
+ dispatch(reloadNow());
|
158
|
154
|
|
159
|
155
|
return true;
|
160
|
156
|
}
|
|
@@ -166,8 +162,18 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
166
|
162
|
* @returns {ReactElement}
|
167
|
163
|
*/
|
168
|
164
|
render() {
|
169
|
|
- const { t } = this.props;
|
170
|
|
- const { message, timeLeft, title } = this.state;
|
|
165
|
+ const { isNetworkFailure, t } = this.props;
|
|
166
|
+ const { timeLeft } = this.state;
|
|
167
|
+
|
|
168
|
+ let message, title;
|
|
169
|
+
|
|
170
|
+ if (isNetworkFailure) {
|
|
171
|
+ title = 'dialog.conferenceDisconnectTitle';
|
|
172
|
+ message = 'dialog.conferenceDisconnectMsg';
|
|
173
|
+ } else {
|
|
174
|
+ title = 'dialog.conferenceReloadTitle';
|
|
175
|
+ message = 'dialog.conferenceReloadMsg';
|
|
176
|
+ }
|
171
|
177
|
|
172
|
178
|
return (
|
173
|
179
|
<ConfirmDialog
|
|
@@ -187,9 +193,8 @@ class PageReloadDialog extends Component<IPageReloadDialogProps, IPageReloadDial
|
187
|
193
|
* @param {Object} state - The redux state.
|
188
|
194
|
* @protected
|
189
|
195
|
* @returns {{
|
190
|
|
- * message: string,
|
191
|
|
- * reason: string,
|
192
|
|
- * title: string
|
|
196
|
+ * isNetworkFailure: boolean,
|
|
197
|
+ * reason: string
|
193
|
198
|
* }}
|
194
|
199
|
*/
|
195
|
200
|
function mapStateToProps(state: IReduxState) {
|