Skip to content

Commit

Permalink
fix(admin-ui): Fix stack overflow when datetime picker inside a list
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Nov 23, 2023
1 parent 84764b1 commit f7b4f46
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import dayjs from 'dayjs';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { distinctUntilChanged, map } from 'rxjs/operators';

import { dayOfWeekIndex } from './constants';
import { CalendarView, DayCell, DayOfWeek } from './types';
Expand All @@ -19,7 +19,10 @@ export class DatetimePickerService {
private jumping = false;

constructor() {
this.selected$ = this.selectedDatetime$.pipe(map(value => value && value.toDate()));
this.selected$ = this.selectedDatetime$.pipe(
map(value => value && value.toDate()),
distinctUntilChanged((a, b) => a?.getTime() === b?.getTime()),
);
this.viewing$ = this.viewingDatetime$.pipe(map(value => value.toDate()));
this.weekStartDayIndex = dayOfWeekIndex['mon'];
this.calendarView$ = combineLatest(this.viewingDatetime$, this.selectedDatetime$).pipe(
Expand Down

0 comments on commit f7b4f46

Please sign in to comment.