ui: finalize PR

This commit is contained in:
Aaron Greenspan
2021-01-20 17:14:32 -07:00
committed by Aiden McClelland
parent 39accaa382
commit ba04b7c431
3 changed files with 3 additions and 26 deletions

View File

@@ -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<void>()
private embassy: PropertySubject<S9Server>
@@ -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<S9Server>, timestamp: Date = new Date()): void {
if (this.lastUpdateTimestamp > timestamp) return
@@ -90,7 +77,7 @@ export class ServerModel {
async restoreCache (): Promise<void> {
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