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 b3bf5ca68ee81345281e21db12dc13eae6aafdf4..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.allComments.keywords === 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); + } } diff --git a/src/app/components/shared/tag-cloud/tag-cloud.component.ts b/src/app/components/shared/tag-cloud/tag-cloud.component.ts index 65145b71b18ad2d57619a063e5a9b8930488b9cf..122763e8f6d42fb9d8b1ec255e0fbe660c0ff5ac 100644 --- a/src/app/components/shared/tag-cloud/tag-cloud.component.ts +++ b/src/app/components/shared/tag-cloud/tag-cloud.component.ts @@ -156,7 +156,7 @@ const getDefaultCloudParameters = (): CloudParameters => { templateUrl: './tag-cloud.component.html', styleUrls: ['./tag-cloud.component.scss'] }) -export class TagCloudComponent implements OnInit, OnDestroy, AfterContentInit, AfterViewInit { +export class TagCloudComponent implements OnInit, OnDestroy, AfterContentInit { @ViewChild(TCloudComponent, { static: false }) child: TCloudComponent; @ViewChild(TagCloudPopUpComponent) popup: TagCloudPopUpComponent; @@ -303,15 +303,11 @@ export class TagCloudComponent implements OnInit, OnDestroy, AfterContentInit, A ngAfterContentInit() { document.getElementById('footer_rescale').style.display = 'none'; this._calcFont = window.getComputedStyle(document.getElementById('tagCloudComponent')).fontFamily; - this.dataManager.bindToRoom(this.roomId, this.userRole); + setTimeout(() => this.dataManager.bindToRoom(this.roomId, this.userRole)); this.dataManager.updateDemoData(this.translateService); this.setCloudParameters(TagCloudComponent.getCurrentCloudParameters(), false); } - ngAfterViewInit() { - setTimeout(() => this.rebuildData()); - } - ngOnDestroy() { document.getElementById('footer_rescale').style.display = 'block'; this.headerInterface.unsubscribe(); diff --git a/src/app/services/util/tag-cloud-data.service.ts b/src/app/services/util/tag-cloud-data.service.ts index d3762dcdaec95eb0141190c5d59a87129fabf7e1..7d60e8387a74f260a8c69a66de61ea027e095d81 100644 --- a/src/app/services/util/tag-cloud-data.service.ts +++ b/src/app/services/util/tag-cloud-data.service.ts @@ -154,8 +154,12 @@ export class TagCloudDataService { } bindToRoom(roomId: string, userRole: UserRole): void { + if (this._subscriptionAdminData) { + throw new Error('Room already bound.'); + } this._currentFilter = CommentFilter.currentFilter; this._roomId = roomId; + this._lastFetchedComments = null; this._subscriptionAdminData = this._tagCloudAdmin.getAdminData.subscribe(adminData => { this.onReceiveAdminData(adminData, true); }); @@ -181,6 +185,7 @@ export class TagCloudDataService { unbindRoom(): void { this._subscriptionAdminData.unsubscribe(); + this._subscriptionAdminData = null; if (this._commentSubscription !== null) { this._commentSubscription.unsubscribe(); this._commentSubscription = null; diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts index 429b18536bb7972f494a1db0c14dcf45d1bc5765..6c88ce2f853386f1d9971e8f29c9613552fc9a72 100644 --- a/src/app/services/util/topic-cloud-admin.service.ts +++ b/src/app/services/util/topic-cloud-admin.service.ts @@ -146,9 +146,12 @@ export class TopicCloudAdminService { this.roomService.getRoom(roomId).subscribe(room => { this.blacklistActive = room.blacklistIsActive; const adminData = TopicCloudAdminService.getDefaultAdminData; - adminData.blacklistIsActive = room.blacklistIsActive; - adminData.profanityFilter = room.profanityFilter; - this.setAdminData(adminData, false, userRole); + if (adminData.blacklistIsActive !== room.blacklistIsActive || + adminData.profanityFilter !== room.profanityFilter) { + adminData.blacklistIsActive = room.blacklistIsActive; + adminData.profanityFilter = room.profanityFilter; + this.setAdminData(adminData, false, userRole); + } }); } diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index ee83a9cf445fde352caf535b4a2480fb1e109cc2..a7290cce09b4a10c5bba6212de125835ce4db2e9 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -404,6 +404,7 @@ "keyword-delete": "keyword deleted", "keyword-edit": "keyword renamed", "keywords-merge": "keywords merged", + "spacy-labels": "Which nouns of the text analysis should be displayed as topics?", "changes-gone-wrong": "somthing has gone wrong", "english": "English", "german": "German",