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
This commit is contained in:
Matt Hill
2022-08-29 14:59:09 -06:00
committed by GitHub
parent 8cd2fac9b9
commit 705653465a
27 changed files with 247 additions and 184 deletions

View File

@@ -0,0 +1,30 @@
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) {}
}