Skip to content

Commit 266e159

Browse files
committed
fix: fix infinite load on universal with day and week view
Closes #1177
1 parent c6d0556 commit 266e159

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

projects/angular-calendar/src/modules/week/calendar-week-view-current-time-marker.component.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {
22
Component,
33
Input,
4+
NgZone,
45
OnChanges,
56
SimpleChanges,
67
TemplateRef
78
} from '@angular/core';
89
import { BehaviorSubject, interval, Observable } from 'rxjs';
9-
import { switchMapTo, startWith, map } from 'rxjs/operators';
10+
import { switchMapTo, startWith, map, switchMap } from 'rxjs/operators';
1011
import { DateAdapter } from '../../date-adapters/date-adapter';
1112

1213
@Component({
@@ -62,9 +63,11 @@ export class CalendarWeekViewCurrentTimeMarkerComponent implements OnChanges {
6263

6364
private columnDate$ = new BehaviorSubject<Date>(this.columnDate);
6465

65-
marker$: Observable<{ isVisible: boolean; top: number }> = interval(
66-
60 * 1000
67-
).pipe(
66+
marker$: Observable<{
67+
isVisible: boolean;
68+
top: number;
69+
}> = this.zone.onStable.pipe(
70+
switchMap(() => interval(60 * 1000)),
6871
startWith(0),
6972
switchMapTo(this.columnDate$),
7073
map(columnDate => {
@@ -91,7 +94,7 @@ export class CalendarWeekViewCurrentTimeMarkerComponent implements OnChanges {
9194
})
9295
);
9396

94-
constructor(private dateAdapter: DateAdapter) {}
97+
constructor(private dateAdapter: DateAdapter, private zone: NgZone) {}
9598

9699
ngOnChanges(changes: SimpleChanges) {
97100
if (changes.columnDate) {

0 commit comments

Comments
 (0)