From 848ed2cb0a9623cac325988ddd4b47a1c1b7da7e Mon Sep 17 00:00:00 2001 From: Ruben Bimberg <ruben.bimberg@mni.thm.de> Date: Mon, 12 Jul 2021 14:09:43 +0200 Subject: [PATCH] Change detection of old rooms --- .../topic-cloud-filter.component.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts b/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts index 9eb077c9e..2b521760b 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts +++ b/src/app/components/shared/_dialogs/topic-cloud-filter/topic-cloud-filter.component.ts @@ -67,9 +67,7 @@ export class TopicCloudFilterComponent implements OnInit { this.allComments = this.getCommentCounts(this.comments); this.filteredComments = this.getCommentCounts(this.comments.filter(comment => this.tmpFilter.checkComment(comment))); this.commentsLoadedCallback(); - this.hasNoKeywords = this.comments.length >= 3 && - this.comments.every(comment => !comment.keywordsFromSpacy || comment.keywordsFromSpacy.length === 0) && - !WorkerDialogComponent.isWorkingOnRoom(data.room.id); + this.hasNoKeywords = this.isUpdatable(); }); this.eventService.broadcast('pushCurrentRoomData'); } @@ -137,4 +135,23 @@ export class TopicCloudFilterComponent implements OnInit { this.dialogRef.close(this.router.navigateByUrl(this.target)); }; } + + private isUpdatable(): boolean { + if (this.comments.length < 3) { + return false; + } + let count = 0; + let newCount = 0; + this.comments.forEach(comment => { + if (comment.keywordsFromSpacy && comment.keywordsFromSpacy.length) { + newCount++; + } else { + count++; + } + }); + if (count * 2 / 3 < newCount) { + return false; + } + return !WorkerDialogComponent.isWorkingOnRoom(this._room.id); + } } -- GitLab