FIX: Attempt to connect with navigator.onLine is initially false (#22981)

This commit is contained in:
Mark VanLandingham 2023-08-04 09:43:45 -05:00 committed by GitHub
parent 1d58dcac1f
commit 14348fc2f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -13,8 +13,6 @@ export default class NetworkConnectivity extends Service {
constructor() {
super(...arguments);
this.setConnectivity(navigator.onLine);
window.addEventListener("offline", () => {
this.setConnectivity(false);
this.startTimerToCheckNavigator();
@ -23,6 +21,10 @@ export default class NetworkConnectivity extends Service {
window.addEventListener("online", this.pingServerAndSetConnectivity);
window.addEventListener("visibilitychange", this.onFocus);
if (!navigator.onLine) {
this.pingServerAndSetConnectivity();
}
}
@bind