From 58a95c5a4b95259a4e0e2b28b35b89f6aea22b56 Mon Sep 17 00:00:00 2001 From: midzelis Date: Fri, 15 Aug 2025 01:22:02 +0000 Subject: [PATCH] Fix code quality issues in timeline components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fix variable naming consistency (leadout → leadOut) • Remove unused props from timeline-asset-viewer interface • Add styleMarginRightOverride prop for dynamic margin control • Simplify skeleton component styling --- .../timeline-viewer/timeline-viewer.svelte | 370 ------------------ .../base-timeline-viewer.svelte | 8 +- .../base-components/base-timeline.svelte | 18 +- .../timeline/base-components/scrubber.svelte | 6 +- .../timeline/base-components/skeleton.svelte | 6 +- .../timeline-asset-viewer.svelte | 28 +- .../lib/components/timeline/timeline.svelte | 7 + .../(user)/utilities/geolocation/+page.svelte | 6 +- 8 files changed, 36 insertions(+), 413 deletions(-) delete mode 100644 web/src/lib/components/timeline-viewer/timeline-viewer.svelte diff --git a/web/src/lib/components/timeline-viewer/timeline-viewer.svelte b/web/src/lib/components/timeline-viewer/timeline-viewer.svelte deleted file mode 100644 index ccf601a2fe..0000000000 --- a/web/src/lib/components/timeline-viewer/timeline-viewer.svelte +++ /dev/null @@ -1,370 +0,0 @@ - - - - -{@render header?.(scrollTop)} - - -
((timelineManager.viewportWidth = v), updateSlidingWindow())} - bind:this={element} - onscroll={() => (handleTimelineScroll(), updateSlidingWindow(), updateIsScrolling())} -> -
-
- {@render children?.()} - {#if isEmpty} - - {@render empty?.()} - {/if} -
- - {#each timelineManager.months as monthGroup (monthGroup.viewId)} - {@const display = monthGroup.intersecting} - {@const absoluteHeight = monthGroup.top} - - {#if !monthGroup.isLoaded} -
- -
- {:else if display} -
- -
- {/if} - {/each} - -
-
-
- - - {#if $showAssetViewer} - - {/if} - - - diff --git a/web/src/lib/components/timeline/base-components/base-timeline-viewer.svelte b/web/src/lib/components/timeline/base-components/base-timeline-viewer.svelte index be890f2e5b..cc493ef94f 100644 --- a/web/src/lib/components/timeline/base-components/base-timeline-viewer.svelte +++ b/web/src/lib/components/timeline/base-components/base-timeline-viewer.svelte @@ -30,6 +30,7 @@ showArchiveIcon?: boolean; showSkeleton?: boolean; isShowDeleteConfirmation?: boolean; + styleMarginRightOverride?: string; onAssetOpen?: (dayGroup: DayGroup, asset: TimelineAsset, defaultAssetOpen: () => void) => void; onSelect?: (asset: TimelineAsset) => void; header?: Snippet<[handleScrollTop: (top: number) => void]>; @@ -49,6 +50,7 @@ withStacked = false, showSkeleton = $bindable(true), showArchiveIcon = false, + styleMarginRightOverride, isShowDeleteConfirmation = $bindable(false), onAssetOpen, @@ -63,10 +65,8 @@ let element: HTMLElement | undefined = $state(); let timelineElement: HTMLElement | undefined = $state(); - let scrubberWidth = $state(0); const maxMd = $derived(mobileDevice.maxMd); - const usingMobileDevice = $derived(mobileDevice.pointerCoarse); const isEmpty = $derived(timelineManager.isInitialized && timelineManager.months.length === 0); $effect(() => { @@ -213,7 +213,7 @@ }; const updateIsScrolling = () => (timelineManager.scrolling = true); - // note: don't throttle, debounch, or otherwise do this function async - it causes flicker + // note: don't throttle, debounce, or otherwise do this function async - it causes flicker const updateSlidingWindow = () => timelineManager.updateSlidingWindow(element?.scrollTop || 0); const scrollCompensation = ({ heightDelta, scrollTop }: { heightDelta?: number; scrollTop?: number }) => { @@ -249,7 +249,7 @@
((timelineManager.viewportWidth = v), updateSlidingWindow())} diff --git a/web/src/lib/components/timeline/base-components/base-timeline.svelte b/web/src/lib/components/timeline/base-components/base-timeline.svelte index 5d239470ce..32e18cf10b 100644 --- a/web/src/lib/components/timeline/base-components/base-timeline.svelte +++ b/web/src/lib/components/timeline/base-components/base-timeline.svelte @@ -26,8 +26,8 @@ showSkeleton?: boolean; isShowDeleteConfirmation?: boolean; + onAssetOpen?: (dayGroup: DayGroup, asset: TimelineAsset, defaultAssetOpen: () => void) => void; onSelect?: (asset: TimelineAsset) => void; - onEscape?: () => void; children?: Snippet; empty?: Snippet; @@ -51,16 +51,16 @@ empty, }: Props = $props(); - let leadout = $state(false); + let leadOut = $state(false); let scrubberMonthPercent = $state(0); let scrubberMonth: { year: number; month: number } | undefined = $state(undefined); let scrubOverallPercent: number = $state(0); let scrubberWidth: number = $state(0); - // note: don't throttle, debounch, or otherwise make this function async - it causes flicker + // note: don't throttle, debounce, or otherwise make this function async - it causes flicker // this function updates the scrubber position based on the current scroll position in the timeline const handleTimelineScroll = () => { - leadout = false; + leadOut = false; if (timelineManager.timelineHeight < timelineManager.viewportHeight * 2) { // edge case - scroll limited due to size of content, must adjust - use the overall percent instead @@ -119,7 +119,7 @@ top = next; } if (!found) { - leadout = true; + leadOut = true; scrubberMonth = undefined; scrubberMonthPercent = 0; scrubOverallPercent = 1; @@ -127,7 +127,7 @@ } }; - // note: don't throttle, debounch, or otherwise make this function async - it causes flicker + // note: don't throttle, debounce, or otherwise make this function async - it causes flicker // this function scrolls the timeline to the specified month group and offset, based on scrubber interaction const onScrub: ScrubberListener = ({ scrubberMonth, @@ -167,7 +167,8 @@ export const scrollToAsset = (asset: TimelineAsset) => baseTimelineViewer?.scrollToAsset(asset) ?? false; - void; @@ -34,7 +34,7 @@ scrubOverallPercent = 0, scrubberMonthPercent = 0, scrubberMonth = undefined, - leadout = false, + leadOut = false, onScrub = undefined, onScrubKeyDown = undefined, startScrub = undefined, @@ -100,7 +100,7 @@ offset += scrubberMonthPercent * relativeBottomOffset; } return offset; - } else if (leadout) { + } else if (leadOut) { let offset = relativeTopOffset; for (const segment of segments) { offset += segment.height; diff --git a/web/src/lib/components/timeline/base-components/skeleton.svelte b/web/src/lib/components/timeline/base-components/skeleton.svelte index 7ce2c3cee3..4ede4e0024 100644 --- a/web/src/lib/components/timeline/base-components/skeleton.svelte +++ b/web/src/lib/components/timeline/base-components/skeleton.svelte @@ -13,11 +13,7 @@ > {title} -
+