fix: hard link navigation (#18489)

This commit is contained in:
Alex 2025-05-23 08:21:37 -05:00 committed by GitHub
parent 2fa7a40996
commit 4878c500a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 56 additions and 31 deletions

View file

@ -124,26 +124,38 @@
scrollTo(0);
};
const scrollToAsset = async (assetId: string) => {
try {
const bucket = await assetStore.findBucketForAsset(assetId);
if (bucket) {
const height = bucket.findAssetAbsolutePosition(assetId);
if (height) {
scrollTo(height);
assetStore.updateIntersections();
return true;
}
}
} catch {
// ignore errors - asset may not be in the store
}
return false;
};
const completeNav = async () => {
const scrollTarget = $gridScrollTarget?.at;
let scrolled = false;
if (scrollTarget) {
try {
const bucket = await assetStore.findBucketForAsset(scrollTarget);
if (bucket) {
const height = bucket.findAssetAbsolutePosition(scrollTarget);
if (height) {
scrollTo(height);
assetStore.updateIntersections();
return;
}
}
} catch {
// ignore errors - asset may not be in the store
}
scrolled = await scrollToAsset(scrollTarget);
}
if (!scrolled) {
// if the asset is not found, scroll to the top
scrollToTop();
}
scrollToTop();
};
beforeNavigate(() => (assetStore.suspendTransitions = true));
afterNavigate((nav) => {
const { complete } = nav;
complete.then(completeNav, completeNav);