diff --git a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts index c31b1c07b82be48a13f1ee09433c0431094c82eb..1dade371dd1b6504407451e4b598bb2f5d73a721 100644 --- a/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts +++ b/src/app/components/moderator/moderator-comment-list/moderator-comment-list.component.ts @@ -352,8 +352,6 @@ export class ModeratorCommentListComponent implements OnInit, OnDestroy { // set current filters to local storage for later use localStorage.setItem('currentFilters', JSON.stringify(this.currentFilter)); - localStorage.setItem('currentPeriod', JSON.stringify(this.period)); - localStorage.setItem('currentFromNowTimestamp', JSON.stringify(this.fromNow)); // can be null } clickedUserNumber(usrNumber: number): void { @@ -429,6 +427,10 @@ export class ModeratorCommentListComponent implements OnInit, OnDestroy { } else { this.commentsFilteredByTime = this.comments; } + + localStorage.setItem('currentPeriod', JSON.stringify(this.period)); + localStorage.setItem('currentFromNowTimestamp', JSON.stringify(this.fromNow)); // can be null + this.filterComments(this.currentFilter); } } 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 cb7475de63cb0897dcda81936cbe582fac3160ae..f9a117285a364ae69e3d2e6d6c5dac67fb557bfb 100644 --- a/src/app/components/shared/comment-list/comment-list.component.ts +++ b/src/app/components/shared/comment-list/comment-list.component.ts @@ -508,8 +508,6 @@ export class CommentListComponent implements OnInit, OnDestroy { // set current filters to local storage for later use localStorage.setItem('currentFilters', JSON.stringify(this.currentFilter)); - localStorage.setItem('currentPeriod', JSON.stringify(this.period)); - localStorage.setItem('currentFromNowTimestamp', JSON.stringify(this.fromNow)); // can be null } sort(array: any[], type: string): any[] { @@ -643,6 +641,9 @@ export class CommentListComponent implements OnInit, OnDestroy { this.commentsFilteredByTime = this.comments; } + localStorage.setItem('currentPeriod', JSON.stringify(this.period)); + localStorage.setItem('currentFromNowTimestamp', JSON.stringify(this.fromNow)); // can be null + this.filterComments(this.currentFilter); this.titleService.attachTitle('(' + this.commentsFilteredByTime.length + ')'); } diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index a6828e2a01255442f49a89b7699acc7c8cc1eff6..4d88c290ed1653305666fb0af22f06e335da5114 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -100,12 +100,11 @@ export class CommentService extends BaseHttpService { filter(com : Comment) : boolean { /* Get Filter Options */ - const currentFilters = localStorage.getItem('currentFilters'); - const period = localStorage.getItem('currentPeriod'); - const timestamp = localStorage.getItem('currentFromNowTimestamp'); + const currentFilters = JSON.parse(localStorage.getItem('currentFilters')); + const period = JSON.parse(localStorage.getItem('currentPeriod')); + const timestamp = JSON.parse(localStorage.getItem('currentFromNowTimestamp')); /* Filter by Period */ - /* const currentTime = new Date(); const hourInSeconds = 3600000; let periodInSeconds; @@ -149,8 +148,6 @@ export class CommentService extends BaseHttpService { return false; } - */ - /* Other Filters */ const read = 'read'; const unread = 'unread';