mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
fix: reset sideload service after websocket completes (#2798)
* fix: reset sideload service after websocket completes * chore: fix comment
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user