From 110607d9f7bbdaaafbd5bf576c7441b05ad9ffe2 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Mon, 22 Jan 2024 16:34:59 +0100 Subject: [PATCH] fix: avoid too many calendar requests when tracking --- src/app/features/timeline/timeline.component.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/features/timeline/timeline.component.ts b/src/app/features/timeline/timeline.component.ts index 346b0c2367..a406c491e7 100644 --- a/src/app/features/timeline/timeline.component.ts +++ b/src/app/features/timeline/timeline.component.ts @@ -1,6 +1,13 @@ import { ChangeDetectionStrategy, Component, OnDestroy } from '@angular/core'; import { TimelineCalendarMapEntry, TimelineViewEntry } from './timeline.model'; -import { debounceTime, map, startWith, switchMap, tap } from 'rxjs/operators'; +import { + debounceTime, + distinctUntilChanged, + map, + startWith, + switchMap, + tap, +} from 'rxjs/operators'; import { TaskService } from '../tasks/task.service'; import { combineLatest, forkJoin, Observable, of } from 'rxjs'; import { mapToTimelineViewEntries } from './map-timeline-data/map-to-timeline-view-entries'; @@ -23,6 +30,7 @@ import { selectCalendarProviders } from '../config/store/global-config.reducer'; import { CalendarIntegrationService } from '../calendar-integration/calendar-integration.service'; import { selectAllCalendarTaskEventIds } from '../tasks/store/task.selectors'; import { CalendarIntegrationEvent } from '../calendar-integration/calendar-integration.model'; +import { distinctUntilChangedObject } from '../../util/distinct-until-changed-object'; @Component({ selector: 'timeline', @@ -45,6 +53,7 @@ export class TimelineComponent implements OnDestroy { })), ), ), + distinctUntilChanged(distinctUntilChangedObject), switchMap(({ allCalendarTaskEventIds, calendarProviders }) => { return calendarProviders && calendarProviders.length ? forkJoin( @@ -123,7 +132,6 @@ export class TimelineComponent implements OnDestroy { data: { isInfoShownInitially: true }, }); } - this.icalEvents$.subscribe((v) => console.log(`icalEvents$`, v)); } ngOnDestroy(): void {