Fix/os update version (#2890)

* dynamically set a registry to use for os updates

* fix os updates response type

* fix saving high score

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
Lucy
2025-04-23 09:17:46 -04:00
committed by GitHub
parent 5b173315f9
commit df4c92672f
13 changed files with 184 additions and 48 deletions

View File

@@ -1,17 +1,17 @@
import { Injectable } from '@angular/core'
import { PatchDB } from 'patch-db-client'
import { BehaviorSubject, distinctUntilChanged, map, combineLatest } from 'rxjs'
import { OSUpdate } from 'src/app/services/api/api.types'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { getServerInfo } from 'src/app/utils/get-server-info'
import { DataModel } from './patch-db/data-model'
import { Version } from '@start9labs/start-sdk'
import { RR } from './api/api.types'
@Injectable({
providedIn: 'root',
})
export class OSService {
osUpdate?: OSUpdate
osUpdate?: RR.GetRegistryOsUpdateRes
updateAvailable$ = new BehaviorSubject<boolean>(false)
readonly updating$ = this.patch.watch$('serverInfo', 'statusInfo').pipe(
@@ -48,9 +48,9 @@ export class OSService {
async loadOS(): Promise<void> {
const { version, id } = await getServerInfo(this.patch)
this.osUpdate = await this.api.checkOSUpdate({ serverId: id })
const [latestVersion, _] = Object.entries(this.osUpdate).at(-1)!
const updateAvailable =
Version.parse(this.osUpdate.version).compare(Version.parse(version)) ===
'greater'
Version.parse(latestVersion).compare(Version.parse(version)) === 'greater'
this.updateAvailable$.next(updateAvailable)
}
}