Files
zitadel/console/src/app/services/update.service.ts
T
RamonandGitHub e47acaeef2 chore(console): Angular 20 #10690 (#10768)
# Which Problems Are Solved


# How the Problems Are Solved

# Additional Changes

# Additional Context
- Closes #10690
2025-10-08 07:10:50 +00:00

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();
});
}
}