mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 22:02:15 +00:00
# Which Problems Are Solved # How the Problems Are Solved # Additional Changes # Additional Context - Closes #10690
31 lines
775 B
TypeScript
31 lines
775 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
import { SwUpdate } from '@angular/service-worker';
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
import { NEVER, switchMap } from 'rxjs';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class UpdateService {
|
|
constructor(
|
|
private swUpdate: SwUpdate,
|
|
snackbar: MatSnackBar,
|
|
) {
|
|
this.swUpdate.versionUpdates
|
|
.pipe(
|
|
switchMap((event) => {
|
|
if (event.type !== 'VERSION_DETECTED') {
|
|
return NEVER;
|
|
}
|
|
|
|
return snackbar.open('Update Available', 'Reload').onAction();
|
|
}),
|
|
takeUntilDestroyed(),
|
|
)
|
|
.subscribe(() => {
|
|
window.location.reload();
|
|
});
|
|
}
|
|
}
|