refactor loaders, better err toasts, rework Embassy tab organization

This commit is contained in:
Matt Hill
2021-07-20 16:57:20 -06:00
committed by Aiden McClelland
parent 2ff9c622ac
commit eb245aea50
58 changed files with 492 additions and 610 deletions

View File

@@ -1,9 +1,8 @@
import { Component, Input, OnInit } from '@angular/core'
import { BehaviorSubject, from, Subject } from 'rxjs'
import { takeUntil } from 'rxjs/operators'
import { markAsLoadingDuring$ } from 'src/app/services/loader.service'
import { capitalizeFirstLetter } from 'src/app/util/misc.util'
import { Loadable } from '../loadable'
import { Loadable, markAsLoadingDuring$ } from '../loadable'
import { WizardAction } from '../wizard-types'
@Component({

View File

@@ -2,9 +2,8 @@ import { Component, Input, OnInit } from '@angular/core'
import { BehaviorSubject, from, Subject } from 'rxjs'
import { takeUntil, tap } from 'rxjs/operators'
import { Breakages } from 'src/app/services/api/api.types'
import { markAsLoadingDuring$ } from 'src/app/services/loader.service'
import { capitalizeFirstLetter, isEmptyObject } from 'src/app/util/misc.util'
import { Loadable } from '../loadable'
import { Loadable, markAsLoadingDuring$ } from '../loadable'
import { WizardAction } from '../wizard-types'
@Component({

View File

@@ -1,4 +1,6 @@
import { BehaviorSubject, Subject } from 'rxjs'
import { BehaviorSubject, Observable, Subject } from 'rxjs'
import { concatMap, finalize } from 'rxjs/operators'
import { fromSync$, emitAfter$ } from 'src/app/util/rxjs.util'
export interface Loadable {
load: (prevResult?: any) => void
@@ -7,3 +9,16 @@ export interface Loadable {
cancel$: Subject<void> // will cancel load function
}
export function markAsLoadingDuring$<T> ($trigger$: Subject<boolean>, o: Observable<T>): Observable<T> {
let shouldBeOn = true
const displayIfItsBeenAtLeast = 5 // ms
return fromSync$(() => {
emitAfter$(displayIfItsBeenAtLeast).subscribe(() => { if (shouldBeOn) $trigger$.next(true) })
}).pipe(
concatMap(() => o),
finalize(() => {
$trigger$.next(false)
shouldBeOn = false
}),
)
}