mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
fix: address TODOs and close dialogs upon state change
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { APP_INITIALIZER, Provider } from '@angular/core'
|
||||
import { APP_INITIALIZER, inject, Provider } from '@angular/core'
|
||||
import { UntypedFormBuilder } from '@angular/forms'
|
||||
import { Router, RouteReuseStrategy } from '@angular/router'
|
||||
import { IonicRouteStrategy, IonNav } from '@ionic/angular'
|
||||
import { RELATIVE_URL, THEME, WorkspaceConfig } from '@start9labs/shared'
|
||||
import { TUI_ICONS_PATH } from '@taiga-ui/core'
|
||||
import { TUI_DIALOGS_CLOSE, TUI_ICONS_PATH } from '@taiga-ui/core'
|
||||
import { PatchDB } from 'patch-db-client'
|
||||
import { filter, pairwise } from 'rxjs'
|
||||
import {
|
||||
PATCH_CACHE,
|
||||
PatchDbSource,
|
||||
} from 'src/app/services/patch-db/patch-db-source'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
import { ApiService } from './services/api/embassy-api.service'
|
||||
import { MockApiService } from './services/api/embassy-mock-api.service'
|
||||
import { LiveApiService } from './services/api/embassy-live-api.service'
|
||||
@@ -58,6 +60,17 @@ export const APP_PROVIDERS: Provider[] = [
|
||||
provide: TUI_ICONS_PATH,
|
||||
useValue: (name: string) => `/assets/taiga-ui/icons/${name}.svg#${name}`,
|
||||
},
|
||||
{
|
||||
provide: TUI_DIALOGS_CLOSE,
|
||||
useFactory: () =>
|
||||
inject(StateService).pipe(
|
||||
pairwise(),
|
||||
filter(
|
||||
([prev, curr]) =>
|
||||
prev === 'running' && (curr === 'error' || curr === 'initializing'),
|
||||
),
|
||||
),
|
||||
},
|
||||
]
|
||||
|
||||
export function appInitializer(
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
bufferTime,
|
||||
catchError,
|
||||
filter,
|
||||
skip,
|
||||
startWith,
|
||||
switchMap,
|
||||
take,
|
||||
@@ -41,8 +42,8 @@ export class PatchDbSource extends Observable<Update<DataModel>[]> {
|
||||
catchError((_, original$) => {
|
||||
this.state.retrigger()
|
||||
|
||||
// @TODO Alex this is returning right away and crashing the browser, but we need to wait until state emits again from the retrigger() above.
|
||||
return this.state.pipe(
|
||||
skip(1), // skipping previous value stored due to shareReplay
|
||||
filter(current => current === 'running'),
|
||||
take(1),
|
||||
switchMap(() => original$),
|
||||
|
||||
@@ -111,7 +111,7 @@ export class StateService extends Observable<RR.ServerState | null> {
|
||||
),
|
||||
),
|
||||
)
|
||||
.subscribe() // @TODO Alex shouldn't this be subscribed in app component with the others? Do we ever need to unsubscribe?
|
||||
.subscribe()
|
||||
|
||||
constructor() {
|
||||
super(subscriber => this.stream$.subscribe(subscriber))
|
||||
|
||||
Reference in New Issue
Block a user