From ba04b7c4311c8ad9d9225f18e0ce46e1d1eec437 Mon Sep 17 00:00:00 2001 From: Aaron Greenspan Date: Wed, 20 Jan 2021 17:14:32 -0700 Subject: [PATCH] ui: finalize PR --- ui/src/app/models/server-model.ts | 15 +-------------- ui/src/app/services/os-update.service.ts | 12 +----------- ui/use-mocks.json | 2 +- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/ui/src/app/models/server-model.ts b/ui/src/app/models/server-model.ts index cd73d6871..54b15700a 100644 --- a/ui/src/app/models/server-model.ts +++ b/ui/src/app/models/server-model.ts @@ -7,16 +7,10 @@ import { Storage } from '@ionic/storage' import { throttleTime, delay } from 'rxjs/operators' import { StorageKeys } from './storage-keys' -export enum ServerModelState { - BOOT, - LOCALSTORAGE, - LIVE, -} @Injectable({ providedIn: 'root', }) export class ServerModel { - $modelState$ = new BehaviorSubject(ServerModelState.BOOT) lastUpdateTimestamp: Date $delta$ = new Subject() private embassy: PropertySubject @@ -32,7 +26,6 @@ export class ServerModel { ).subscribe(() => { this.commitCache() }) - this.$modelState$.subscribe(s => console.log('model state', s)) } // client fxns @@ -44,12 +37,6 @@ export class ServerModel { return peekProperties(this.embassy) } - nextState (s: ServerModelState) { - this.$modelState$.subscribe(s2 => { - if (s > s2) this.$modelState$.next(s) - }) - } - update (update: Partial, timestamp: Date = new Date()): void { if (this.lastUpdateTimestamp > timestamp) return @@ -90,7 +77,7 @@ export class ServerModel { async restoreCache (): Promise { const emb = await this.storage.get(StorageKeys.SERVER_CACHE_KEY) - if (emb && emb.versionInstalled === this.config.version) this.update(emb, new Date()) + if (emb && emb.versionInstalled === this.config.version) this.update(emb) } // server state change diff --git a/ui/src/app/services/os-update.service.ts b/ui/src/app/services/os-update.service.ts index b581811e7..a450e0293 100644 --- a/ui/src/app/services/os-update.service.ts +++ b/ui/src/app/services/os-update.service.ts @@ -38,7 +38,7 @@ export class OsUpdateService { this.serverModel.watch().versionInstalled.pipe(take(1)), this.apiService.getVersionLatest(), ]).pipe( - map(([vi, vl]) => updateIsAvailable(this.emver, vi, vl.versionLatest)), + map(([vi, vl]) => this.updateIsAvailable(vi, vl.versionLatest) ? vl : undefined), catchError(e => { console.error(`OsUpdateService Error: ${e}`) return of(undefined) @@ -59,11 +59,6 @@ export class OsUpdateService { } } - async checkForAppsUpdate (): Promise { - const availableApps = await this.apiService.getAvailableApps() - return !!availableApps.find(app => this.emver.compare(app.versionInstalled, app.versionLatest) === -1) - } - async updateEmbassyOS (versionLatest: string): Promise { await this.apiService.updateAgent(versionLatest) this.serverModel.update({ status: ServerStatus.UPDATING }) @@ -71,8 +66,3 @@ export class OsUpdateService { await this.navCtrl.navigateRoot('/embassy') } } - -function updateIsAvailable (e: Emver, vi: string, vl: string): string | undefined { - if (!vi || !vl) return undefined - return e.compare(vi, vl) === -1 ? vl : undefined -} \ No newline at end of file diff --git a/ui/use-mocks.json b/ui/use-mocks.json index 2caee7215..3425efc8a 100644 --- a/ui/use-mocks.json +++ b/ui/use-mocks.json @@ -1,3 +1,3 @@ { - "useMocks": true + "useMocks": false }