Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
check for presence of cdr before doing a mark for check
Browse files Browse the repository at this point in the history
Signed-off-by: bryanl <bryanliles@gmail.com>
  • Loading branch information
bryanl committed Apr 29, 2020
1 parent 891d5d4 commit 4e3d0e7
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions web/src/app/modules/shared/pipes/relative/relative.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ export class RelativePipe implements PipeTransform, OnDestroy {

const then = now.getTime() / 1000 - ts;

const updateInterval = this.changeDetectionFrequency(then) * 1000;
const updateInterval = changeDetectionFrequency(then) * 1000;

this.timer = this.ngZone.runOutsideAngular(() => {
if (typeof window !== 'undefined') {
return window.setTimeout(() => {
this.ngZone.run(() => this.changeDetectorRef.markForCheck());
this.ngZone.run(() => {
if (this.changeDetectorRef) {
this.changeDetectorRef.markForCheck();
}
});
}, updateInterval);
}
return null;
Expand All @@ -73,17 +77,17 @@ export class RelativePipe implements PipeTransform, OnDestroy {
this.timer = null;
}
}
}

private changeDetectionFrequency(seconds: number) {
switch (true) {
case seconds < 60:
return 1;
case seconds < 3600:
return 60;
case seconds < 86400:
return 600;
default:
return 3600;
}
const changeDetectionFrequency = (seconds: number) => {
switch (true) {
case seconds < 60:
return 1;
case seconds < 3600:
return 60;
case seconds < 86400:
return 600;
default:
return 3600;
}
}
};

0 comments on commit 4e3d0e7

Please sign in to comment.