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 9eb077c9ef468839f93877e71a022f4813f6cc0f..2b521760bb44d67a84fddebc8ee3ed764e286231 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); + } }