fix(app): scroll to a timeline month once and stop at the end of the list

A month chosen on the timeline scrolled the grid on every later page load;
it now scrolls once, gives up when no page is left (or only server cards
show), and saved views notice the search text once its delay has passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 16:29:01 +00:00
1 parent 20b9654c33
commit f4579ef64c
2 files changed
+21 -9

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ public partial class LibraryView : UserControl
}
/// <summary>A month of the timeline: the Library narrows to its year and the grid scrolls to it.</summary>
private void OnSlotActivated(object sender, ChartItemEventArgs e) => Model?.ShowMonth(e.Row, e.Column);
private void OnSlotActivated(object sender, ChartItemEventArgs e) => Model?.ShowSlot(e.Row, e.Column);
/// <summary>"Saved views" and "Rate ▾" open their menu under themselves.</summary>
private void OnOpenMenu(object sender, RoutedEventArgs e)
+20 -8
View File
@@ -67,6 +67,7 @@ public sealed class LibraryViewModel : SectionViewModel
private LibraryTimeline _timeline = LibraryTimeline.Empty;
private IReadOnlyList<ChartRow> _timelineBands = [];
private (int Year, int Month)? _timelineMonth;
private bool _scrollToMonth;
private bool _isLoading;
private bool _hasLoaded;
private bool _suppressReload;
@@ -100,6 +101,7 @@ public sealed class LibraryViewModel : SectionViewModel
_searchDelay.Tick += (_, _) =>
{
_searchDelay.Stop();
RaiseViews();
Reload();
};
_syncDelay = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
@@ -354,15 +356,21 @@ public sealed class LibraryViewModel : SectionViewModel
/// <summary>Photos per month in the culture's digits.</summary>
public Func<double, string> CountFormatter { get; } = v => Formatting.Count((long)v);
/// <summary>A month of the timeline was clicked (band and slot of <see cref="TimelineBands"/>).</summary>
public void ShowSlot(int band, int slot)
{
if (_timeline.MonthAt(band, slot) is { } month) ShowMonth(month.Year, month.Month);
}
/// <summary>
/// A month of the timeline was clicked: the Library narrows to its year and the grid scrolls to its first sequence
/// Shows a month of the timeline: the Library narrows to its year and the grid scrolls to its first sequence
/// (loading further pages until it is there).
/// </summary>
public void ShowMonth(int band, int slot)
public void ShowMonth(int year, int month)
{
if (_timeline.MonthAt(band, slot) is not { } month) return;
_timelineMonth = month;
var option = Years.FirstOrDefault(o => o.Value == month.Year);
_timelineMonth = (year, month);
_scrollToMonth = true;
var option = Years.FirstOrDefault(o => o.Value == year);
if (option is not null && option != _year) SelectedYear = option;
else _ = ScrollToMonthAsync();
OnPropertyChanged(nameof(TimelineBand));
@@ -594,20 +602,22 @@ public sealed class LibraryViewModel : SectionViewModel
RaiseState();
RaiseMass();
}
if (_timelineMonth is not null) await ScrollToMonthAsync();
if (_scrollToMonth) await ScrollToMonthAsync();
}
/// <summary>Brings the first sequence of the chosen timeline month into sight, loading pages until it is there.</summary>
/// <summary>Brings the first sequence of the chosen timeline month into sight once, loading pages until it is there.</summary>
private async Task ScrollToMonthAsync()
{
if (_timelineMonth is not { } month || _year.Value != month.Year) return;
var index = LibraryTimeline.FirstOfMonth([.. Items.Select(i => i.Sequence)], month.Year, month.Month);
if (index >= 0)
{
_scrollToMonth = false;
ScrollRequested?.Invoke(Items[index]);
return;
}
if (_pager is { HasMore: true, IsLoading: false }) await LoadMoreAsync();
if (_pager is { HasMore: true, IsLoading: false } && _origin.Value != OriginFilter.Server) await LoadMoreAsync();
else _scrollToMonth = false;
}
private async Task LoadViewsAsync()
@@ -762,6 +772,7 @@ public sealed class LibraryViewModel : SectionViewModel
SelectedTag = Tags[0];
SelectedOrigin = Origins[0];
_timelineMonth = null;
_scrollToMonth = false;
_suppressReload = false;
Reload();
}
@@ -783,6 +794,7 @@ public sealed class LibraryViewModel : SectionViewModel
OnPropertyChanged(nameof(SelectedSort));
OnPropertyChanged(nameof(SortColumn));
_timelineMonth = null;
_scrollToMonth = false;
_suppressReload = false;
RaiseViews();
Reload();