mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
fix: fix dynamic status and instructions modal (#1382)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { Component, Input, Optional } from '@angular/core'
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { ModalController } from '@ionic/angular'
|
||||
import { defer, isObservable, Observable, of } from 'rxjs'
|
||||
import { catchError, ignoreElements, share } from 'rxjs/operators'
|
||||
|
||||
import { getErrorMessage } from '../../services/error-toast.service'
|
||||
import { AbstractApiService } from '../../services/api.service'
|
||||
import { defer, from, isObservable, Observable, of } from 'rxjs'
|
||||
import { catchError, ignoreElements, share } from 'rxjs/operators'
|
||||
|
||||
@Component({
|
||||
selector: 'markdown',
|
||||
@@ -12,11 +11,12 @@ import { catchError, ignoreElements, share } from 'rxjs/operators'
|
||||
styleUrls: ['./markdown.component.scss'],
|
||||
})
|
||||
export class MarkdownComponent {
|
||||
@Input() contentUrl?: string
|
||||
@Input() content?: string | Observable<string>
|
||||
@Input() title = ''
|
||||
|
||||
private readonly data$ = defer(() => this.contentObservable).pipe(share())
|
||||
private readonly data$ = defer(() =>
|
||||
isObservable(this.content) ? this.content : of(this.content),
|
||||
).pipe(share())
|
||||
|
||||
readonly error$ = this.data$.pipe(
|
||||
ignoreElements(),
|
||||
@@ -25,23 +25,9 @@ export class MarkdownComponent {
|
||||
|
||||
readonly content$ = this.data$.pipe(catchError(() => of([])))
|
||||
|
||||
constructor(
|
||||
private readonly modalCtrl: ModalController,
|
||||
@Optional()
|
||||
private readonly embassyApi: AbstractApiService | null,
|
||||
) {}
|
||||
constructor(private readonly modalCtrl: ModalController) {}
|
||||
|
||||
async dismiss() {
|
||||
return this.modalCtrl.dismiss(true)
|
||||
}
|
||||
|
||||
private get contentObservable() {
|
||||
if (isObservable(this.content)) {
|
||||
return this.content
|
||||
}
|
||||
|
||||
return this.contentUrl
|
||||
? from(this.embassyApi?.getStatic(this.contentUrl))
|
||||
: of(this.content)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ export * from './pipes/shared/trust.pipe'
|
||||
export * from './pipes/unit-conversion/unit-conversion.module'
|
||||
export * from './pipes/unit-conversion/unit-conversion.pipe'
|
||||
|
||||
export * from './services/api.service'
|
||||
export * from './services/destroy.service'
|
||||
export * from './services/emver.service'
|
||||
export * from './services/error-toast.service'
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export abstract class AbstractApiService {
|
||||
// for getting static files: ex icons, instructions, licenses
|
||||
abstract getStatic(url: string): Promise<string>
|
||||
}
|
||||
Reference in New Issue
Block a user