mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
ui: finalize PR
This commit is contained in:
committed by
Aiden McClelland
parent
39accaa382
commit
ba04b7c431
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user