Skip to content

Commit

Permalink
handle error closure events properly
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDHill committed Jan 13, 2025
1 parent 3466aa4 commit 49a6f28
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
10 changes: 9 additions & 1 deletion web/projects/ui/src/app/pages/init/init.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ export class InitService extends Observable<MappedProgress> {
from(this.api.initGetProgress()),
).pipe(
switchMap(({ guid, progress }) =>
this.api.openWebsocket$<T.FullProgress>(guid).pipe(startWith(progress)),
this.api
.openWebsocket$<T.FullProgress>(guid, {
closeObserver: {
next: () => {
this.state.syncState()
},
},
})
.pipe(startWith(progress)),
),
map(({ phases, overall }) => ({
total: getOverallDecimal(overall),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,27 @@ export class SideloadService {

readonly progress$ = this.guid$.pipe(
switchMap(guid =>
this.api.openWebsocket$<T.FullProgress>(guid).pipe(
tap(p => {
if (p.overall === true) {
this.router.navigate([''], { replaceUrl: true })
}
}),
),
this.api
.openWebsocket$<T.FullProgress>(guid, {
closeObserver: {
next: event => {
if (event.code !== 1000) {
this.errorService.handleError(event.reason)
}
},
},
})
.pipe(
tap(p => {
if (p.overall === true) {
this.router.navigate([''], { replaceUrl: true })
}
}),
endWith(null),
),
),
catchError(e => {
this.errorService.handleError(e)
this.errorService.handleError('Websocket connection broken. Try again.')
return EMPTY
}),
shareReplay(1),
Expand Down

0 comments on commit 49a6f28

Please sign in to comment.