This commit is contained in:
Matt Hill
2021-07-06 16:56:39 -06:00
committed by Aiden McClelland
parent 01c6b91c52
commit c4fa205c3d
12 changed files with 79 additions and 68 deletions

View File

@@ -9,7 +9,6 @@ import { parsePropertiesPermissive } from 'src/app/util/properties.util'
import { Mock } from './mock-app-fixures'
import { HttpService } from '../http.service'
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
import { map } from 'rxjs/operators'
@Injectable()
export class MockApiService extends ApiService {
@@ -22,10 +21,9 @@ export class MockApiService extends ApiService {
// every time a patch is returned from the mock, we override its sequence to be 1 more than the last sequence in the patch-db as provided by `o`.
watch$ (store: Store<DataModel>): Observable<Update<DataModel>> {
store.watchCache$().pipe(map(cache => cache.sequence)).subscribe(seq => {
store.sequence$.subscribe(seq => {
console.log('INCOMING: ', seq)
if (this.sequence < seq) {
console.log('hererereree')
this.sequence = seq
}
})

View File

@@ -15,7 +15,7 @@ export class LocalStorageBootstrap implements Bootstrapper<DataModel> {
async init (): Promise<DBCache<DataModel>> {
const cache: DBCache<DataModel> = await this.storage.get(LocalStorageBootstrap.CONTENT_KEY)
return cache || { sequence: 0, data: { } }
return cache || { sequence: 0, data: { } as DataModel }
}
async update (cache: DBCache<DataModel>): Promise<void> {

View File

@@ -18,6 +18,7 @@ export enum ConnectionStatus {
})
export class PatchDbModel {
connectionStatus$ = new BehaviorSubject(ConnectionStatus.Initializing)
data: DataModel
private patchDb: PatchDB<DataModel>
private patchSub: Subscription
@@ -29,6 +30,7 @@ export class PatchDbModel {
async init (): Promise<void> {
const cache = await this.bootstrapper.init()
this.patchDb = new PatchDB(this.sources, cache)
this.data = this.patchDb.store.cache.data
}
start (): void {
@@ -75,7 +77,7 @@ export class PatchDbModel {
return this.connectionStatus$.asObservable()
}
watch$: Store<DataModel> ['watch$'] = (...args: (string | number)[]): Observable<DataModel> => {
watch$: Store<DataModel>['watch$'] = (...args: (string | number)[]): Observable<DataModel> => {
// console.log('WATCHING')
return this.patchDb.store.watch$(...(args as [])).pipe(
tap(cache => console.log('CHANGE IN STORE', cache)),

View File

@@ -1,11 +1,11 @@
import { HealthCheckResultLoading, MainStatusRunning, PackageDataEntry, PackageMainStatus, PackageState, Status } from './patch-db/data-model'
import { HealthCheckResultLoading, MainStatusRunning, PackageMainStatus, PackageState, Status } from './patch-db/data-model'
export function renderPkgStatus (pkg: PackageDataEntry): PkgStatusRendering {
switch (pkg.state) {
export function renderPkgStatus (state: PackageState, status: Status): PkgStatusRendering {
switch (state) {
case PackageState.Installing: return { display: 'Installing', color: 'primary', showDots: true, feStatus: FEStatus.Installing }
case PackageState.Updating: return { display: 'Updating', color: 'primary', showDots: true, feStatus: FEStatus.Updating }
case PackageState.Removing: return { display: 'Removing', color: 'warning', showDots: true, feStatus: FEStatus.Removing }
case PackageState.Installed: return handleInstalledState(pkg.installed.status)
case PackageState.Installed: return handleInstalledState(status)
}
}