From 5294e8f444897fbbfe9888993817ec2b631f2224 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 23 Feb 2026 18:13:33 -0700 Subject: [PATCH] minor cleanup from patch-db audit --- .../ui/src/app/services/os.service.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/web/projects/ui/src/app/services/os.service.ts b/web/projects/ui/src/app/services/os.service.ts index 0c5fb57cb..a34931915 100644 --- a/web/projects/ui/src/app/services/os.service.ts +++ b/web/projects/ui/src/app/services/os.service.ts @@ -2,10 +2,11 @@ import { inject, Injectable } from '@angular/core' import { PatchDB } from 'patch-db-client' import { BehaviorSubject, - distinctUntilChanged, - map, combineLatest, + distinctUntilChanged, firstValueFrom, + map, + shareReplay, } from 'rxjs' import { ApiService } from 'src/app/services/api/embassy-api.service' import { getServerInfo } from 'src/app/utils/get-server-info' @@ -22,17 +23,19 @@ export class OSService { osUpdate?: T.OsVersionInfoMap readonly updateAvailable$ = new BehaviorSubject(false) - readonly updating$ = this.patch.watch$('serverInfo', 'statusInfo').pipe( + private readonly statusInfo$ = this.patch + .watch$('serverInfo', 'statusInfo') + .pipe(shareReplay({ bufferSize: 1, refCount: true })) + + readonly updating$ = this.statusInfo$.pipe( map(status => status.updateProgress ?? status.updated), distinctUntilChanged(), ) - readonly backingUp$ = this.patch - .watch$('serverInfo', 'statusInfo', 'backupProgress') - .pipe( - map(obj => !!obj), - distinctUntilChanged(), - ) + readonly backingUp$ = this.statusInfo$.pipe( + map(status => !!status.backupProgress), + distinctUntilChanged(), + ) readonly updatingOrBackingUp$ = combineLatest([ this.updating$,