Files
start-os/frontend/projects/ui/src/app/services/server-name.service.ts
Matt Hill 705653465a use hostname from patchDB as default server name (#1758)
* replace offline toast with global indicator

* use hostname from patchDB as default server name

* add alert to marketplace delete and reword logout alert
2022-08-29 14:59:09 -06:00

31 lines
792 B
TypeScript

import { Injectable } from '@angular/core'
import { PatchDbService } from './patch-db/patch-db.service'
import { combineLatest, filter, map, Observable } from 'rxjs'
export interface ServerNameInfo {
current: string
default: string
}
@Injectable({ providedIn: 'root' })
export class ServerNameService {
private readonly chosenName$ = this.patch.watch$('ui', 'name')
private readonly hostname$ = this.patch
.watch$('server-info', 'hostname')
.pipe(filter(Boolean))
readonly name$: Observable<ServerNameInfo> = combineLatest([
this.chosenName$,
this.hostname$,
]).pipe(
map(([chosen, hostname]) => {
return {
current: chosen || hostname,
default: hostname,
}
}),
)
constructor(private readonly patch: PatchDbService) {}
}