diff --git a/Makefile b/Makefile index f7fad27d3..9cb5f0b7a 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ frontend/config.json: $(GIT_HASH_FILE) frontend/config-sample.json npm --prefix frontend run-script build-config frontend/patchdb-ui-seed.json: frontend/package.json - jq '."ack-welcome" = $(shell yq '.version' frontend/package.json)' frontend/patchdb-ui-seed.json > ui-seed.tmp + jq '."ack-welcome" = "$(shell yq '.version' frontend/package.json)"' frontend/patchdb-ui-seed.json > ui-seed.tmp mv ui-seed.tmp frontend/patchdb-ui-seed.json patch-db/client/node_modules: patch-db/client/package.json @@ -180,7 +180,7 @@ backend-$(ARCH).tar: $(EMBASSY_BINS) frontends: $(EMBASSY_UIS) # this is a convenience step to build the UI -ui: frontend/dist/ui +ui: frontend/dist/raw/ui # used by github actions backend: $(EMBASSY_BINS) diff --git a/frontend/projects/shared/assets/img/icon_apple_touch.png b/frontend/projects/shared/assets/img/icon_apple_touch.png new file mode 100644 index 000000000..3ca45d443 Binary files /dev/null and b/frontend/projects/shared/assets/img/icon_apple_touch.png differ diff --git a/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.html b/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.html index 0c4ec3543..c63060f12 100644 --- a/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.html +++ b/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.html @@ -1,9 +1,32 @@ - - Your user interface is cached and out of date. Hard refresh the page to get - the latest UI. - - Ok - +
+ + Your user interface is cached and out of date. Hard refresh the page to get + the latest UI. + + Ok + +
+ + + + Your user interface is cached and out of date. +
+
+ Attempt to reload the PWA using the button below. If you continue to see + this message, uninstall and reinstall the PWA. + Reload +
+
diff --git a/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.ts b/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.ts index e9a2e75ae..f039841d3 100644 --- a/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.ts +++ b/frontend/projects/ui/src/app/components/toast-container/refresh-alert/refresh-alert.component.ts @@ -1,7 +1,9 @@ import { ChangeDetectionStrategy, Component, Inject } from '@angular/core' -import { Observable, Subject, merge } from 'rxjs' +import { merge, Observable, Subject } from 'rxjs' import { RefreshAlertService } from './refresh-alert.service' +import { SwUpdate } from '@angular/service-worker' +import { LoadingController } from '@ionic/angular' @Component({ selector: 'refresh-alert', @@ -10,13 +12,36 @@ import { RefreshAlertService } from './refresh-alert.service' }) export class RefreshAlertComponent { private readonly dismiss$ = new Subject() - readonly show$ = merge(this.dismiss$, this.refresh$) + onPwa = false constructor( @Inject(RefreshAlertService) private readonly refresh$: Observable, + private readonly updates: SwUpdate, + private readonly loadingCtrl: LoadingController, ) {} + ngOnInit() { + this.onPwa = window.matchMedia('(display-mode: standalone)').matches + } + + async pwaReload() { + const loader = await this.loadingCtrl.create({ + message: 'Reloading PWA...', + }) + await loader.present() + try { + // attempt to update to the latest client version available + await this.updates.activateUpdate() + } catch (e) { + console.error('Error activating update from service worker: ', e) + } finally { + loader.dismiss() + // always reload, as this resolves most out of sync cases + window.location.reload() + } + } + onDismiss() { this.dismiss$.next(false) } diff --git a/frontend/projects/ui/src/index.html b/frontend/projects/ui/src/index.html index 3cdf84ff5..0248b7462 100644 --- a/frontend/projects/ui/src/index.html +++ b/frontend/projects/ui/src/index.html @@ -14,6 +14,11 @@ + diff --git a/frontend/projects/ui/src/manifest.webmanifest b/frontend/projects/ui/src/manifest.webmanifest index 7895929a7..94e6b08f9 100644 --- a/frontend/projects/ui/src/manifest.webmanifest +++ b/frontend/projects/ui/src/manifest.webmanifest @@ -5,8 +5,8 @@ "background_color": "#1e1e1e", "display": "standalone", "scope": ".", - "start_url": "/", - "id": "/", + "start_url": "/?version=0344", + "id": "/?version=0344", "icons": [ { "src": "assets/img/icon_pwa.png",