diff --git a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts index 2834c7441bf9cc6300ba5edf46a8e4916a18a238..23ee53f0dedabbb01c0a6f5b764386c6439eb4e6 100644 --- a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts +++ b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts @@ -101,13 +101,12 @@ export class CommentSettingsComponent implements OnInit { const settingsReturn = new CommentSettingsDialog(); this.editRoom.directSend = this.directSend; - this.editRoom.threshold = this.commentThreshold; + this.editRoom.threshold = this.settingThreshold ? this.commentThreshold : 0; this.editRoom.moderated = this.enableCommentModeration; // If moderation isn't enabled, the direct send is of no interest and shouldn't be updated to avoid confusion about missing comments if ((this.enableCommentModeration && !this.directSend) || this.directSend) { - this.roomService.updateRoom(this.editRoom).subscribe(x => { - }); + this.roomService.updateRoom(this.editRoom).subscribe(); settingsReturn.directSend = this.directSend; } settingsReturn.enableModeration = this.enableCommentModeration; diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts index 2a746b20e4d83cb1c91b94e8c88af70ff0650e8b..94e0bebd71b7be2c35bbb73938a2c8daeeff8fcc 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -348,21 +348,8 @@ export class CommentListComponent implements OnInit, OnDestroy { } getComments(): void { - if (this.room.threshold) { - this.thresholdEnabled = true; - } else { - this.thresholdEnabled = false; - } + this.thresholdEnabled = !!this.room.threshold; this.isLoading = false; - let commentThreshold; - if (this.thresholdEnabled) { - commentThreshold = this.room.threshold; - if (this.hideCommentsList) { - this.filteredComments = this.filteredComments.filter(x => x.score >= commentThreshold); - } else { - this.setComments(this.comments.filter(x => x.score >= commentThreshold)); - } - } this.setTimePeriod(); } @@ -601,6 +588,7 @@ export class CommentListComponent implements OnInit, OnDestroy { this.period = period; this.fromNow = null; } + const comments = this.thresholdEnabled ? this.comments.filter(x => x.score >= this.room.threshold) : this.comments; const currentTime = new Date(); const hourInSeconds = 3600000; let periodInSeconds; @@ -627,11 +615,11 @@ export class CommentListComponent implements OnInit, OnDestroy { periodInSeconds = hourInSeconds * 336; break; } - this.commentsFilteredByTime = this.comments + this.commentsFilteredByTime = comments .filter(c => new Date(c.timestamp).getTime() >= (this.period === Period.fromNow ? this.fromNow : (currentTime.getTime() - periodInSeconds))); } else { - this.commentsFilteredByTime = this.comments; + this.commentsFilteredByTime = comments; } this.filterComments(this.currentFilter, this.currentFilterCompare); diff --git a/src/app/components/shared/comment/comment.component.ts b/src/app/components/shared/comment/comment.component.ts index 563184abe51f96c93b7da93dba4a4d06805cb18e..b80a72ead71f51758d2d3b56d5b8f559d1f3c1ac 100644 --- a/src/app/components/shared/comment/comment.component.ts +++ b/src/app/components/shared/comment/comment.component.ts @@ -109,7 +109,7 @@ export class CommentComponent implements OnInit, AfterViewInit { const subscription = this.roomDataService.checkProfanity(this.comment).subscribe(e => { if (e !== null) { this.isProfanity = e; - subscription.unsubscribe(); + setTimeout(() => subscription.unsubscribe()); } }); } diff --git a/src/app/directives/accessibility-escaped-input.directive.ts b/src/app/directives/accessibility-escaped-input.directive.ts index bc2f956795ccb9c84a248fb6eae047f8ef1b98f0..1e518050e8fd1887351b708feac458b61c0d9007 100644 --- a/src/app/directives/accessibility-escaped-input.directive.ts +++ b/src/app/directives/accessibility-escaped-input.directive.ts @@ -14,7 +14,7 @@ export class AccessibilityEscapedInputDirective implements AfterViewInit { const elem = this.reference.nativeElement; elem.addEventListener('focus', this.focus.bind(this)); elem.addEventListener('blur', this.blur.bind(this)); - if (document.activeElement && document.activeElement.contains(elem)) { + if (elem && document.activeElement && elem.contains(document.activeElement)) { this.focus(); } }