diff --git a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts index 202337fd01c85fb1402c711ada462c5f4f6cebbe..0de00f7c58a7f94b08dcebf1500ebb3b86c706b5 100644 --- a/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts +++ b/src/app/components/shared/_dialogs/topic-cloud-administration/topic-cloud-administration.component.ts @@ -123,15 +123,15 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { } ngOnInit(): void { - this.isCreatorOrMod = (this.data.user.role !== UserRole.PARTICIPANT); + this.isCreatorOrMod = this.data ? (this.data.user.role !== UserRole.PARTICIPANT) : true; this.fillListOfLabels(); this.translateService.use(localStorage.getItem('currentLang')); this.checkIfThereAreQuestions(); this.sortQuestions(); - this.roomService.getRoom(localStorage.getItem('roomId')).subscribe(room => { - this.topicCloudAdminService.setBlacklist(room.blacklist); - this.setDefaultAdminData(); - }); + // this.roomService.getRoom(localStorage.getItem('roomId')).subscribe(room => { + // this.topicCloudAdminService.setBlacklist(room.blacklist); + // this.setDefaultAdminData(); + // }); } ngOnDestroy(){ @@ -172,7 +172,8 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { } getBlacklist() { - return this.topicCloudAdminService.getBlacklist(); + return []; + // return this.topicCloudAdminService.getBlacklist(); } sortQuestions(sortMode?: string) { @@ -309,7 +310,7 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { } addBlacklistWord() { - this.topicCloudAdminService.addToBlacklistWordList(this.newBlacklistWord); + this.topicCloudAdminService.addWordToBlacklist(this.newBlacklistWord); this.newBlacklistWord = undefined; if (this.searchMode){ this.searchKeyword(); diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts index 90942eabe553fdd2a07fc77aa95bcaa8e609a1a9..2b704ae556dace97a8bb23c8a44aaeb07bbf77d6 100644 --- a/src/app/services/util/topic-cloud-admin.service.ts +++ b/src/app/services/util/topic-cloud-admin.service.ts @@ -35,9 +35,9 @@ export class TopicCloudAdminService { // TODO: send only words that are contained in keywords words = words.concat(this.profanityWords).concat(this.getProfanityList()); } - if (blacklistFilter && this.blacklist.length > 0) { - words = words.concat(this.blacklist); - } + // if (blacklistFilter && this.blacklist.length > 0) { + // words = words.concat(this.blacklist); + // } return words; } @@ -107,13 +107,15 @@ export class TopicCloudAdminService { } getRoom(): Observable<Room> { - return this.roomService.getRoom(localStorage.getItem('RoomId')); + return this.roomService.getRoom(localStorage.getItem('roomId')); } addWordToBlacklist(word: string) { if (word !== undefined) { this.getRoom().subscribe(room => { - room.blacklist = JSON.parse(room.blacklist).push(word); + const newlist = room.blacklist.length > 0 ? JSON.parse(room.blacklist) : []; + newlist.push(word); + room.blacklist = JSON.stringify(newlist); this.updateRoom(room); }); } @@ -122,8 +124,12 @@ export class TopicCloudAdminService { removeWordFromBlacklist(word: string) { if (word !== undefined) { this.getRoom().subscribe(room => { - room.blacklist = JSON.parse(room.blacklist).splice(room.blacklist.indexOf(word, 1));; - this.updateRoom(room); + if (room.blacklist.length > 0){ + const newlist = JSON.parse(room.blacklist); + newlist.splice(newlist.indexOf(word, 0), 1); + room.blacklist = JSON.stringify(newlist); + this.updateRoom(room); + } }); } }