mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +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 { UntypedFormBuilder } from '@angular/forms'
|
||||||
import { Router, RouteReuseStrategy } from '@angular/router'
|
import { Router, RouteReuseStrategy } from '@angular/router'
|
||||||
import { IonicRouteStrategy, IonNav } from '@ionic/angular'
|
import { IonicRouteStrategy, IonNav } from '@ionic/angular'
|
||||||
import { RELATIVE_URL, THEME, WorkspaceConfig } from '@start9labs/shared'
|
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 { PatchDB } from 'patch-db-client'
|
||||||
|
import { filter, pairwise } from 'rxjs'
|
||||||
import {
|
import {
|
||||||
PATCH_CACHE,
|
PATCH_CACHE,
|
||||||
PatchDbSource,
|
PatchDbSource,
|
||||||
} from 'src/app/services/patch-db/patch-db-source'
|
} 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 { ApiService } from './services/api/embassy-api.service'
|
||||||
import { MockApiService } from './services/api/embassy-mock-api.service'
|
import { MockApiService } from './services/api/embassy-mock-api.service'
|
||||||
import { LiveApiService } from './services/api/embassy-live-api.service'
|
import { LiveApiService } from './services/api/embassy-live-api.service'
|
||||||
@@ -58,6 +60,17 @@ export const APP_PROVIDERS: Provider[] = [
|
|||||||
provide: TUI_ICONS_PATH,
|
provide: TUI_ICONS_PATH,
|
||||||
useValue: (name: string) => `/assets/taiga-ui/icons/${name}.svg#${name}`,
|
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(
|
export function appInitializer(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
bufferTime,
|
bufferTime,
|
||||||
catchError,
|
catchError,
|
||||||
filter,
|
filter,
|
||||||
|
skip,
|
||||||
startWith,
|
startWith,
|
||||||
switchMap,
|
switchMap,
|
||||||
take,
|
take,
|
||||||
@@ -41,8 +42,8 @@ export class PatchDbSource extends Observable<Update<DataModel>[]> {
|
|||||||
catchError((_, original$) => {
|
catchError((_, original$) => {
|
||||||
this.state.retrigger()
|
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(
|
return this.state.pipe(
|
||||||
|
skip(1), // skipping previous value stored due to shareReplay
|
||||||
filter(current => current === 'running'),
|
filter(current => current === 'running'),
|
||||||
take(1),
|
take(1),
|
||||||
switchMap(() => original$),
|
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() {
|
constructor() {
|
||||||
super(subscriber => this.stream$.subscribe(subscriber))
|
super(subscriber => this.stream$.subscribe(subscriber))
|
||||||
|
|||||||
Reference in New Issue
Block a user