fix: opening hours pipe refreshing too often

This commit is contained in:
Rainer Killinger
2022-12-07 17:14:18 +01:00
parent 31bfd4a8a4
commit 95e1734d26
2 changed files with 8 additions and 2 deletions

View File

@@ -115,7 +115,7 @@ export class StringSplitPipe implements PipeTransform {
@Injectable()
@Pipe({
name: 'openingHours',
pure: false,
pure: true,
})
export class OpeningHoursPipe implements PipeTransform, OnDestroy {
locale: string;

View File

@@ -55,7 +55,13 @@ export class OpeningHoursComponent implements OnDestroy, OnInit {
const millisecondsRemaining =
// eslint-disable-next-line unicorn/prefer-date-now
(ohObject.getNextChange()?.getTime() ?? 0) - new Date().getTime();
(ohObject.getNextChange()?.getTime() ?? 0) - new Date().getTime() + 1000;
if (millisecondsRemaining > 1_209_600_000) {
// setTimeout has upper bound of 0x7FFFFFFF
// ignore everything over a week
return;
}
if (millisecondsRemaining > 0) {
this.timer = setTimeout(() => {