mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 04:36:19 -04:00
fix(web): timeline renders nothing with an invalid asset scroll target (#16994)
* fix(web): fix asset grid showing nothing with an invalid asset target * Deduplicate * Scroll to position where appropriate * a bit cleaner * fix: lint --------- Co-authored-by: Min Idzelis <min123@gmail.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
3c87341902
commit
b00da18e84
@ -82,26 +82,33 @@
|
|||||||
let bottomSectionHeight = 60;
|
let bottomSectionHeight = 60;
|
||||||
let leadout = $state(false);
|
let leadout = $state(false);
|
||||||
|
|
||||||
const completeNav = async () => {
|
const scrollTo = (top: number) => {
|
||||||
if ($gridScrollTarget?.at) {
|
element?.scrollTo({ top });
|
||||||
try {
|
|
||||||
const bucket = await assetStore.findBucketForAsset($gridScrollTarget.at);
|
|
||||||
if (bucket) {
|
|
||||||
const height = bucket.findAssetAbsolutePosition($gridScrollTarget.at);
|
|
||||||
if (height) {
|
|
||||||
element?.scrollTo({ top: height });
|
|
||||||
showSkeleton = false;
|
showSkeleton = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const scrollToTop = () => {
|
||||||
|
scrollTo(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
const completeNav = async () => {
|
||||||
|
const scrollTarget = $gridScrollTarget?.at;
|
||||||
|
if (scrollTarget) {
|
||||||
|
try {
|
||||||
|
const bucket = await assetStore.findBucketForAsset(scrollTarget);
|
||||||
|
if (bucket) {
|
||||||
|
const height = bucket.findAssetAbsolutePosition(scrollTarget);
|
||||||
|
if (height) {
|
||||||
|
scrollTo(height);
|
||||||
assetStore.updateIntersections();
|
assetStore.updateIntersections();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
element?.scrollTo({ top: 0 });
|
// ignore errors - asset may not be in the store
|
||||||
showSkeleton = false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
element?.scrollTo({ top: 0 });
|
|
||||||
showSkeleton = false;
|
|
||||||
}
|
}
|
||||||
|
scrollToTop();
|
||||||
};
|
};
|
||||||
beforeNavigate(() => (assetStore.suspendTransitions = true));
|
beforeNavigate(() => (assetStore.suspendTransitions = true));
|
||||||
afterNavigate((nav) => {
|
afterNavigate((nav) => {
|
||||||
@ -134,8 +141,7 @@
|
|||||||
{ replaceState: true, forceNavigate: true },
|
{ replaceState: true, forceNavigate: true },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
element?.scrollTo({ top: 0 });
|
scrollToTop();
|
||||||
showSkeleton = false;
|
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user