mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix: hard link navigation (#18489)
This commit is contained in:
parent
2fa7a40996
commit
4878c500a5
2 changed files with 56 additions and 31 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue