Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 10bfad2

Browse files
authored
fix: download model wrong event mits (#895)
1 parent 6ee8e6b commit 10bfad2

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

cortex-js/src/infrastructure/controllers/events.controller.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
1616
import { ApiOperation, ApiTags } from '@nestjs/swagger';
1717
import {
1818
Observable,
19+
asyncScheduler,
1920
catchError,
2021
combineLatest,
2122
from,
@@ -50,25 +51,15 @@ export class EventsController {
5051
const latestDownloadState$: Observable<DownloadStateEvent> = of({
5152
data: this.downloadManagerService.getDownloadStates(),
5253
});
53-
54-
const downloadAbortEvent$ = fromEvent<DownloadState[]>(
55-
this.eventEmitter,
56-
'download.event.aborted',
57-
).pipe(map((downloadState) => ({ data: downloadState })));
58-
5954
const downloadEvent$ = fromEvent<DownloadState[]>(
6055
this.eventEmitter,
6156
'download.event',
6257
).pipe(
6358
map((downloadState) => ({ data: downloadState })),
64-
throttleTime(1000, undefined, { leading: true, trailing: true }),
59+
throttleTime(1000, asyncScheduler, { trailing: true }),
6560
);
6661

67-
return merge(
68-
latestDownloadState$,
69-
downloadEvent$,
70-
downloadAbortEvent$,
71-
).pipe();
62+
return merge(latestDownloadState$, downloadEvent$).pipe();
7263
}
7364

7465
@ApiOperation({

cortex-js/src/infrastructure/services/download-manager/download-manager.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class DownloadManagerService {
3434
this.allDownloadStates = this.allDownloadStates.filter(
3535
(downloadState) => downloadState.id !== downloadId,
3636
);
37-
this.eventEmitter.emit('download.event.aborted', this.allDownloadStates);
37+
this.eventEmitter.emit('download.event', this.allDownloadStates);
3838
}
3939

4040
async submitDownloadRequest(

0 commit comments

Comments
 (0)