From 5906225de6dc8b57543fba30aff56268506d102a Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 22 Feb 2021 12:05:40 +0200 Subject: [PATCH] improved bulk performance --- .../project-overview-screen.component.ts | 2 +- apps/red-ui/src/app/state/app-state.service.ts | 17 ++++++++++------- apps/red-ui/src/main.ts | 1 - 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts index 967f2e535..c30ec9fa2 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts +++ b/apps/red-ui/src/app/screens/project-overview-screen/project-overview-screen.component.ts @@ -173,7 +173,7 @@ export class ProjectOverviewScreenComponent implements OnInit, OnDestroy { } reloadProjects() { - this.appStateService.getFiles().then(() => { + this.appStateService.getFiles(this.appStateService.activeProject, false).then(() => { this.calculateData(); }); } diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index d68fe4843..424f94bb3 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -202,7 +202,7 @@ export class AppStateService { return this.getProjectById(projectId).files.find((file) => file.fileId === fileId); } - async loadAllProjects() { + async loadAllProjects(emitEvents: boolean = true) { const projects = await this._projectControllerService.getProjects().toPromise(); if (projects) { const mappedProjects = projects.map((p) => { @@ -213,7 +213,8 @@ export class AppStateService { for (const projectId of Object.keys(fileData)) { this._processFiles( mappedProjects.find((p) => p.projectId === projectId), - fileData[projectId] + fileData[projectId], + emitEvents ); } @@ -244,16 +245,16 @@ export class AppStateService { return activeFileWrapper; } - async getFiles(project?: ProjectWrapper) { + async getFiles(project?: ProjectWrapper, emitEvents: boolean = true) { if (!project) { project = this.activeProject; } const files = await this._statusControllerService.getProjectStatus(project.project.projectId).toPromise(); - return this._processFiles(project, files); + return this._processFiles(project, files, emitEvents); } - private _processFiles(project: ProjectWrapper, files: FileStatus[]) { + private _processFiles(project: ProjectWrapper, files: FileStatus[], emitEvents: boolean = true) { const oldFiles = [...project.files]; const fileStatusChangedEvent = []; @@ -285,8 +286,10 @@ export class AppStateService { project.files = files.map((f) => new FileStatusWrapper(f, this._userService.getNameForId(f.currentReviewer))); this._computeStats(); - fileReanalysedEvent.forEach((file) => this.fileReanalysed.emit(file)); - fileStatusChangedEvent.forEach((file) => this.fileChanged.emit(file)); + if (emitEvents) { + fileReanalysedEvent.forEach((file) => this.fileReanalysed.emit(file)); + fileStatusChangedEvent.forEach((file) => this.fileChanged.emit(file)); + } return files; } diff --git a/apps/red-ui/src/main.ts b/apps/red-ui/src/main.ts index 692f5d296..276cf1624 100644 --- a/apps/red-ui/src/main.ts +++ b/apps/red-ui/src/main.ts @@ -9,7 +9,6 @@ if (environment.production) { enableProdMode(); } -platformBrowserDynamic(); platformBrowserDynamic() .bootstrapModule(AppModule) .then((moduleRef) => {