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 scrollAndLoadAsset = async (assetId: string) => {
|
||||||
const monthGroup = await timelineManager.findMonthGroupForAsset(assetId);
|
try {
|
||||||
if (!monthGroup) {
|
// This flag prevents layout deferral to fix scroll positioning issues.
|
||||||
return false;
|
// 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) => {
|
const scrollToAsset = (asset: TimelineAsset) => {
|
||||||
|
|||||||
@ -140,7 +140,7 @@ export class DayGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
layout(options: CommonLayoutOptions, noDefer: boolean) {
|
layout(options: CommonLayoutOptions, noDefer: boolean) {
|
||||||
if (!noDefer && !this.monthGroup.intersecting) {
|
if (!noDefer && !this.monthGroup.intersecting && !this.monthGroup.timelineManager.isScrollingOnLoad) {
|
||||||
this.#deferredLayout = true;
|
this.#deferredLayout = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,7 @@ export class TimelineManager extends VirtualScrollManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
isInitialized = $state(false);
|
isInitialized = $state(false);
|
||||||
|
isScrollingOnLoad = false;
|
||||||
months: MonthGroup[] = $state([]);
|
months: MonthGroup[] = $state([]);
|
||||||
albumAssets: Set<string> = new SvelteSet();
|
albumAssets: Set<string> = new SvelteSet();
|
||||||
scrubberMonths: ScrubberMonth[] = $state([]);
|
scrubberMonths: ScrubberMonth[] = $state([]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user