forked from MapComplete/MapComplete
Feature: add online indicator
This commit is contained in:
parent
efeb5ae1d9
commit
76dbf50db1
3 changed files with 44 additions and 0 deletions
19
src/Logic/Web/IsOnline.ts
Normal file
19
src/Logic/Web/IsOnline.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { Store, UIEventSource } from "../UIEventSource"
|
||||
|
||||
export class IsOnline {
|
||||
private static readonly _isOnline: UIEventSource<boolean> = new UIEventSource(navigator.onLine)
|
||||
static {
|
||||
|
||||
window.addEventListener("online", () => {
|
||||
IsOnline._isOnline.set(true)
|
||||
})
|
||||
|
||||
window.addEventListener("offline", () => {
|
||||
IsOnline._isOnline.set(false)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
public static readonly isOnline: Store<boolean> = IsOnline._isOnline
|
||||
|
||||
}
|
4
src/service-worker/SWGenerated.ts
Normal file
4
src/service-worker/SWGenerated.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export class SWGenerated {
|
||||
// generated by scripts/prepareServiceWorker.ts
|
||||
static vNumber = "0.54.4"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue