Skip to content

Commit 790a4ae

Browse files
committed
fix(edulint): dedupe requests
1 parent f649cbd commit 790a4ae

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/app/components/tasks/task-module/task-module-programming/task-module-programming.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class TaskModuleProgrammingComponent implements OnInit, OnDestroy {
9696
if (result.result === 'ok') {
9797
this.lintCode();
9898
}
99-
})
99+
}),
100+
shareReplay(1),
100101
);
101102
(this.codeRun$ = this.codeRunResult$.pipe(mapTo(undefined))).subscribe(() => {
102103
this.codeRun$ = null;

src/app/services/tasks/edulint.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
33
import { APIService, Configuration, WebService } from '../../../api/edulint';
44
import { environment } from '../../../environments/environment';
55
import { combineLatest, Observable, of } from 'rxjs';
6-
import { catchError, filter, map, mergeMap } from 'rxjs/operators';
6+
import {catchError, filter, map, mergeMap, shareReplay, take} from 'rxjs/operators';
77
import { EdulintReport } from '../../models';
88

99
@Injectable({
@@ -31,13 +31,17 @@ export class EdulintService {
3131
code += `\n# edulint: config=${this.config}\n`;
3232

3333
return this.linter.apiCodePost({code}).pipe(
34+
take(1),
35+
shareReplay(1),
3436
catchError((e) => {
3537
environment.logger.error('[EduLint] Code post error', e);
3638
return of({hash: undefined});
3739
}),
3840
filter((response) => response.hash !== undefined),
3941
map(response => `${response.hash}`),
4042
mergeMap((hash) => combineLatest([this.linter.analyzeUploaded(this.version, hash), of(hash)])),
43+
take(1),
44+
shareReplay(1),
4145
map(([problems, hash]) => ({
4246
problems,
4347
editorUrl: `${this.url}/editor/${hash}`

0 commit comments

Comments
 (0)