Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): timeline renders nothing with an invalid asset scroll target #16994

Merged
merged 7 commits into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions web/src/lib/components/photos-page/asset-grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,33 @@
let bottomSectionHeight = 60;
let leadout = $state(false);

const scrollTo = (top: number) => {
element?.scrollTo({ top });
showSkeleton = false;
};

const scrollToTop = () => {
scrollTo(0);
};

const completeNav = async () => {
if ($gridScrollTarget?.at) {
const scrollTarget = $gridScrollTarget?.at;
if (scrollTarget) {
try {
const bucket = await assetStore.findBucketForAsset($gridScrollTarget.at);
const bucket = await assetStore.findBucketForAsset(scrollTarget);
if (bucket) {
const height = bucket.findAssetAbsolutePosition($gridScrollTarget.at);
const height = bucket.findAssetAbsolutePosition(scrollTarget);
if (height) {
element?.scrollTo({ top: height });
showSkeleton = false;
scrollTo(height);
assetStore.updateIntersections();
return;
}
}
} catch {
element?.scrollTo({ top: 0 });
showSkeleton = false;
// ignore errors - asset may not be in the store
}
} else {
element?.scrollTo({ top: 0 });
showSkeleton = false;
}
scrollToTop();
};
beforeNavigate(() => (assetStore.suspendTransitions = true));
afterNavigate((nav) => {
Expand Down Expand Up @@ -134,8 +141,7 @@
{ replaceState: true, forceNavigate: true },
);
} else {
element?.scrollTo({ top: 0 });
showSkeleton = false;
scrollToTop();
}
}, 500);
}
Expand Down
Loading