Merge branch 'rebase/integration/refactors' of github.com:Start9Labs/start-os into rebase/feat/domains

This commit is contained in:
Matt Hill
2023-07-26 11:01:56 -06:00
87 changed files with 3983 additions and 2856 deletions

View File

@@ -2,6 +2,8 @@ import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'
import { Observable, Subject, merge, debounceTime } from 'rxjs'
import { RefreshAlertService } from './refresh-alert.service'
import { SwUpdate } from '@angular/service-worker'
import { LoadingController } from '@ionic/angular'
@Component({
selector: 'refresh-alert',
@@ -13,10 +15,36 @@ export class RefreshAlertComponent {
readonly show$ = merge(this.dismiss$, this.refresh$).pipe(debounceTime(0))
// @TODO use this like we did on 0344
onPwa = false
constructor(
@Inject(RefreshAlertService) private readonly refresh$: Observable<boolean>,
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)
}