From aaa2b8e3d4189f0ef31e9b847b77d5fb8a693ca4 Mon Sep 17 00:00:00 2001 From: mohammad <mohammad.alayoub@mni.thm.de> Date: Mon, 21 Jun 2021 16:17:07 +0200 Subject: [PATCH] optimize refreshing the dialog after editing the profanity list --- .../topic-cloud-administration.component.ts | 23 ++++++------------- .../util/topic-cloud-admin.service.ts | 4 ++-- 2 files changed, 9 insertions(+), 18 deletions(-) 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 a76893264..6154f966e 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 @@ -82,6 +82,7 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { this.profanitywordlist = this.topicCloudAdminService.getProfanityListFromStorage(); this.profanitylistSubscription = this.topicCloudAdminService.getCustomProfanityList().subscribe(list => { this.profanitywordlist = list; + this.refreshKeywords(); }); this.isCreatorOrMod = this.data.user.role !== UserRole.PARTICIPANT; this.translateService.use(localStorage.getItem('currentLang')); @@ -172,8 +173,10 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { this.keywords = []; tempKeywords.forEach(keyword => { keyword.comments.forEach(comment => this.pushInKeywords(comment)); - console.log(this.keywords); }); + if (this.searchMode){ + this.searchKeyword(); + } } pushInKeywords(comment: Comment){ @@ -432,33 +435,19 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { addProfanityWord() { this.topicCloudAdminService.addToProfanityList(this.newProfanityWord); this.newProfanityWord = undefined; - if (this.searchMode){ - this.searchKeyword(); - } - this.ngOnDestroy(); - this.ngOnInit(); } addBlacklistWord() { this.topicCloudAdminService.addWordToBlacklist(this.newBlacklistWord); this.newBlacklistWord = undefined; - if (this.searchMode){ - this.searchKeyword(); - } - this.ngOnDestroy(); - this.ngOnInit(); } removeWordFromProfanityList(word: string) { this.topicCloudAdminService.removeFromProfanityList(word); - this.ngOnDestroy(); - this.ngOnInit(); } removeWordFromBlacklist(word: string) { this.topicCloudAdminService.removeWordFromBlacklist(word); - this.ngOnDestroy(); - this.ngOnInit(); } changeProfanityFilter() { @@ -466,7 +455,9 @@ export class TopicCloudAdministrationComponent implements OnInit, OnDestroy { this.translateService.get('topic-cloud-dialog.words-will-be-overwritten').subscribe(msg => { this.notificationService.show(msg); }); - this.searchKeyword(); + 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 93edcdb06..297b61f4a 100644 --- a/src/app/services/util/topic-cloud-admin.service.ts +++ b/src/app/services/util/topic-cloud-admin.service.ts @@ -92,8 +92,8 @@ export class TopicCloudAdminService { const plist = this.getProfanityListFromStorage(); if (!plist.includes(word.toLowerCase().trim())) { plist.push(word.toLowerCase().trim()); - this.customProfanityWords.next(plist); localStorage.setItem(this.profanityKey, JSON.stringify(plist)); + this.customProfanityWords.next(plist); } } } @@ -101,8 +101,8 @@ export class TopicCloudAdminService { removeFromProfanityList(word: string) { const plist = this.getProfanityListFromStorage(); plist.splice(plist.indexOf(word, 0), 1); - this.customProfanityWords.next(plist); localStorage.setItem(this.profanityKey, JSON.stringify(plist)); + this.customProfanityWords.next(plist); } removeProfanityList() { -- GitLab