Skip to content
Snippets Groups Projects
Commit 6cf16e98 authored by Davut Beyazit's avatar Davut Beyazit
Browse files

Fixed missing parse for JSON data

Fixed period filters not being set if not done in filterTimePeriod
parent ff9a1e59
No related merge requests found
......@@ -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);
}
}
......@@ -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 + ')');
}
......
......@@ -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';
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment