FIX: Attempt to connect with navigator.onLine is initially false (#22981)
This commit is contained in:
parent
1d58dcac1f
commit
14348fc2f5
|
@ -13,8 +13,6 @@ export default class NetworkConnectivity extends Service {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
|
|
||||||
this.setConnectivity(navigator.onLine);
|
|
||||||
|
|
||||||
window.addEventListener("offline", () => {
|
window.addEventListener("offline", () => {
|
||||||
this.setConnectivity(false);
|
this.setConnectivity(false);
|
||||||
this.startTimerToCheckNavigator();
|
this.startTimerToCheckNavigator();
|
||||||
|
@ -23,6 +21,10 @@ export default class NetworkConnectivity extends Service {
|
||||||
window.addEventListener("online", this.pingServerAndSetConnectivity);
|
window.addEventListener("online", this.pingServerAndSetConnectivity);
|
||||||
|
|
||||||
window.addEventListener("visibilitychange", this.onFocus);
|
window.addEventListener("visibilitychange", this.onFocus);
|
||||||
|
|
||||||
|
if (!navigator.onLine) {
|
||||||
|
this.pingServerAndSetConnectivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
|
|
Loading…
Reference in New Issue