fix: deep link to last asset (#23920)

This commit is contained in:
Min Idzelis 2025-11-17 15:12:07 -05:00 committed by GitHub
parent 15e00f82f0
commit 69880ee165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 6 deletions

View File

@ -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) => {

View File

@ -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;
}

View File

@ -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([]);