mirror of
https://github.com/immich-app/immich.git
synced 2025-11-26 08:15:17 -05:00
fix: deep link to last asset (#23920)
This commit is contained in:
parent
15e00f82f0
commit
69880ee165
@ -176,12 +176,24 @@
|
||||
};
|
||||
|
||||
const scrollAndLoadAsset = async (assetId: string) => {
|
||||
const monthGroup = await timelineManager.findMonthGroupForAsset(assetId);
|
||||
if (!monthGroup) {
|
||||
return false;
|
||||
try {
|
||||
// This flag prevents layout deferral to fix scroll positioning issues.
|
||||
// When layouts are deferred and we scroll to an asset at the end of the timeline,
|
||||
// we can calculate the asset's position, but the scrollableElement's scrollHeight
|
||||
// hasn't been updated yet to reflect the new layout. This creates a mismatch that
|
||||
// breaks scroll positioning. By disabling layout deferral in this case, we maintain
|
||||
// the performance benefits of deferred layouts while still supporting deep linking
|
||||
// to assets at the end of the timeline.
|
||||
timelineManager.isScrollingOnLoad = true;
|
||||
const monthGroup = await timelineManager.findMonthGroupForAsset(assetId);
|
||||
if (!monthGroup) {
|
||||
return false;
|
||||
}
|
||||
scrollToAssetPosition(assetId, monthGroup);
|
||||
return true;
|
||||
} finally {
|
||||
timelineManager.isScrollingOnLoad = false;
|
||||
}
|
||||
scrollToAssetPosition(assetId, monthGroup);
|
||||
return true;
|
||||
};
|
||||
|
||||
const scrollToAsset = (asset: TimelineAsset) => {
|
||||
|
||||
@ -140,7 +140,7 @@ export class DayGroup {
|
||||
}
|
||||
|
||||
layout(options: CommonLayoutOptions, noDefer: boolean) {
|
||||
if (!noDefer && !this.monthGroup.intersecting) {
|
||||
if (!noDefer && !this.monthGroup.intersecting && !this.monthGroup.timelineManager.isScrollingOnLoad) {
|
||||
this.#deferredLayout = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ export class TimelineManager extends VirtualScrollManager {
|
||||
});
|
||||
|
||||
isInitialized = $state(false);
|
||||
isScrollingOnLoad = false;
|
||||
months: MonthGroup[] = $state([]);
|
||||
albumAssets: Set<string> = new SvelteSet();
|
||||
scrubberMonths: ScrubberMonth[] = $state([]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user