Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(heatmap): prevent clipped cells and stale range dimensions
Timothy Yin5a14fb5dd92c
diff --git a/app/components/ui/CalendarHeatmap/CalendarHeatmap.vue b/app/components/ui/CalendarHeatmap/CalendarHeatmap.vueindex 18ae27ad..0cc74891 100644--- a/app/components/ui/CalendarHeatmap/CalendarHeatmap.vue+++ b/app/components/ui/CalendarHeatmap/CalendarHeatmap.vue@@ -83,7 +83,9 @@ const i18nLocale = computed<Locale>(() => ({more: t('common.heatmap.legend.more'),}))-const effectiveTooltipUnit = computed(() => props.tooltipUnit ?? t('ui.calendarHeatmap.contributions'))+const effectiveTooltipUnit = computed(+ () => props.tooltipUnit ?? t('ui.calendarHeatmap.contributions'),+)const BASE_SQUARE_SIZE = 10const DAYS_IN_WEEK = 7@@ -128,16 +130,16 @@ const tippyInstances = new Map<HTMLElement, Instance>()let tippySingleton: CreateSingletonInstancefunction initTippy() {+ // Dispose the singleton before its references when the calendar changes.+ // Updating an active singleton with an empty list leaves Popper with no rect.+ tippySingleton?.destroy()+ tippyInstances.forEach((item) => item.destroy())tippyInstances.clear()- if (tippySingleton) {- tippySingleton.setInstances(Array.from(tippyInstances.values()))- } else {- tippySingleton = createSingleton(Array.from(tippyInstances.values()), {- overrides: [],- moveTransition: 'transform 0.1s ease-out',- allowHTML: true,- })- }+ tippySingleton = createSingleton([], {+ overrides: [],+ moveTransition: 'transform 0.1s ease-out',+ allowHTML: true,+ })}function tooltipOptions(day: CalendarItem): string | undefined {@@ -254,8 +256,8 @@ watch()watch(- () => props.vertical,- (v) => {+ [() => props.vertical, () => heatmap.value.weekCount],+ ([v]) => {if (v) {width.value =LEFT_SECTION_WIDTH + SQUARE_SIZE * DAYS_IN_WEEK + RIGHT_SECTION_WIDTH@@ -326,7 +328,6 @@ watch(props.max,props.startDate as Date,)- tippyInstances.forEach((item) => item.destroy())nextTick(initTippy)},)diff --git a/app/components/ui/CalendarHeatmap/Heatmap.ts b/app/components/ui/CalendarHeatmap/Heatmap.tsindex 0192ad54..59cf06a8 100644--- a/app/components/ui/CalendarHeatmap/Heatmap.ts+++ b/app/components/ui/CalendarHeatmap/Heatmap.ts@@ -131,7 +131,10 @@ export class Heatmap {}get weekCount(): number {- return Math.ceil(this.getDaysCount() / Heatmap.DAYS_IN_WEEK)+ return Math.ceil(+ (this.getCountEmptyDaysAtStart() + this.getDaysCount()) /+ Heatmap.DAYS_IN_WEEK,+ )}get calendar(): Calendar {@@ -269,17 +272,22 @@ export class Heatmap {}getCountEmptyDaysAtEnd(): number {- const remainingDays = this.getDaysCount() % Heatmap.DAYS_IN_WEEK- return remainingDays === 0 ? 0 : Heatmap.DAYS_IN_WEEK - remainingDays+ return Heatmap.DAYS_IN_WEEK - 1 - this.endDate.getDay()}getDaysCount(): number {- return (- Math.ceil(- (this.endDate.getTime() - this.startDate.getTime()) /- (1000 * 60 * 60 * 24),- ) + 1+ // Count calendar dates, independent of time of day and daylight saving time.+ const start = Date.UTC(+ this.startDate.getFullYear(),+ this.startDate.getMonth(),+ this.startDate.getDate(),)+ const end = Date.UTC(+ this.endDate.getFullYear(),+ this.endDate.getMonth(),+ this.endDate.getDate(),+ )+ return (end - start) / (1000 * 60 * 60 * 24) + 1}isExactYearRange(): boolean {@@ -303,10 +311,20 @@ export class Heatmap {}private parseDate(date: Date | string): Date {- if (typeof date === 'string') {- return new Date(date)+ // Date-only strings represent local calendar dates, not UTC instants.+ let parsed: Date+ if (typeof date === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(date)) {+ const [year, month, day] = date.split('-').map(Number) as [+ number,+ number,+ number,+ ]+ parsed = new Date(year, month - 1, day)+ } else {+ parsed = new Date(date)}- return new Date(date)+ parsed.setHours(0, 0, 0, 0)+ return parsed}private keyDayParser(date: Date): string {