Files
start-os/web/projects/ui/src/app/app.component.ts
Matt Hill c782bab296 switch all FE to camelCase (#2576)
* switch all fe to camelCase

* switch to camelCase on backend

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
2024-03-24 12:05:59 -06:00

50 lines
1.6 KiB
TypeScript

import { Component, inject, OnInit } from '@angular/core'
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
import { Title } from '@angular/platform-browser'
import { THEME } from '@start9labs/shared'
import { PatchDB } from 'patch-db-client'
import { combineLatest, map, merge, startWith } from 'rxjs'
import { AuthService } from './services/auth.service'
import { ConnectionService } from './services/connection.service'
import { PatchDataService } from './services/patch-data.service'
import { DataModel } from './services/patch-db/data-model'
import { PatchMonitorService } from './services/patch-monitor.service'
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent implements OnInit {
private readonly title = inject(Title)
private readonly patch = inject(PatchDB<DataModel>)
readonly auth = inject(AuthService)
readonly theme$ = inject(THEME)
readonly subscription = merge(
inject(PatchDataService),
inject(PatchMonitorService),
)
.pipe(takeUntilDestroyed())
.subscribe()
readonly offline$ = combineLatest([
inject(ConnectionService).connected$,
this.auth.isVerified$,
this.patch
.watch$('serverInfo', 'statusInfo')
.pipe(startWith({ restarting: false, shuttingDown: false })),
]).pipe(
map(
([verified, connected, status]) =>
verified && (!connected || status.restarting || status.shuttingDown),
),
)
async ngOnInit() {
this.patch
.watch$('ui', 'name')
.subscribe(name => this.title.setTitle(name || 'StartOS'))
}
}