fix: reset sideload service after websocket completes (#2798)

* fix: reset sideload service after websocket completes

* chore: fix comment
This commit is contained in:
Alex Inkin
2024-12-12 03:14:01 +04:00
committed by GitHub
parent c675d0feee
commit e9d851e4d3
4 changed files with 2577 additions and 1919 deletions

4477
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -52,6 +52,7 @@
"@start9labs/emver": "^0.1.5",
"@start9labs/start-sdk": "file:../sdk/baseDist",
"@taiga-ui/addon-charts": "3.96.0",
"@taiga-ui/addon-commerce": "3.96.0",
"@taiga-ui/cdk": "3.96.0",
"@taiga-ui/core": "3.96.0",
"@taiga-ui/experimental": "3.96.0",
@@ -83,7 +84,7 @@
"pbkdf2": "^3.1.2",
"rxjs": "^7.8.1",
"swiper": "^8.2.4",
"ts-matches": "^5.5.1",
"ts-matches": "^6.1.0",
"tslib": "^2.3.0",
"uuid": "^8.3.2",
"zone.js": "^0.11.5"

View File

@@ -6,7 +6,7 @@ import cbor from 'cbor'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { ConfigService } from 'src/app/services/config.service'
import { SideloadService } from './sideload.service'
import { firstValueFrom } from 'rxjs'
import { filter, firstValueFrom } from 'rxjs'
import mime from 'mime'
interface Positions {
@@ -124,7 +124,7 @@ export class SideloadPage {
this.api
.uploadPackage(res.upload, this.toUpload.file!)
.catch(e => console.error(e))
await firstValueFrom(this.sideloadService.websocketConnected$)
await firstValueFrom(this.progress$.pipe(filter(Boolean)))
} catch (e: any) {
this.errorService.handleError(e)
} finally {

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'
import { T } from '@start9labs/start-sdk'
import { endWith, ReplaySubject, shareReplay, Subject, switchMap } from 'rxjs'
import { BehaviorSubject, endWith, shareReplay, Subject, switchMap } from 'rxjs'
import { ApiService } from 'src/app/services/api/embassy-api.service'
@Injectable({
@@ -9,17 +9,9 @@ import { ApiService } from 'src/app/services/api/embassy-api.service'
export class SideloadService {
private readonly guid$ = new Subject<string>()
readonly websocketConnected$ = new ReplaySubject()
readonly progress$ = this.guid$.pipe(
switchMap(guid =>
this.api
.openWebsocket$<T.FullProgress>(guid, {
openObserver: {
next: () => this.websocketConnected$.next(''),
},
})
.pipe(endWith(null)),
this.api.openWebsocket$<T.FullProgress>(guid).pipe(endWith(null)),
),
shareReplay(1),
)