diff --git a/src/Titano.App/Sections/LibraryView.xaml.cs b/src/Titano.App/Sections/LibraryView.xaml.cs
index eddccb0f..43972548 100644
--- a/src/Titano.App/Sections/LibraryView.xaml.cs
+++ b/src/Titano.App/Sections/LibraryView.xaml.cs
@@ -27,7 +27,7 @@ public partial class LibraryView : UserControl
}
/// A month of the timeline: the Library narrows to its year and the grid scrolls to it.
- 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);
/// "Saved views" and "Rate ▾" open their menu under themselves.
private void OnOpenMenu(object sender, RoutedEventArgs e)
diff --git a/src/Titano.App/Sections/LibraryViewModel.cs b/src/Titano.App/Sections/LibraryViewModel.cs
index 4fe509da..17d27789 100644
--- a/src/Titano.App/Sections/LibraryViewModel.cs
+++ b/src/Titano.App/Sections/LibraryViewModel.cs
@@ -67,6 +67,7 @@ public sealed class LibraryViewModel : SectionViewModel
private LibraryTimeline _timeline = LibraryTimeline.Empty;
private IReadOnlyList _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
/// Photos per month in the culture's digits.
public Func CountFormatter { get; } = v => Formatting.Count((long)v);
+ /// A month of the timeline was clicked (band and slot of ).
+ public void ShowSlot(int band, int slot)
+ {
+ if (_timeline.MonthAt(band, slot) is { } month) ShowMonth(month.Year, month.Month);
+ }
+
///
- /// 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).
///
- 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();
}
- /// Brings the first sequence of the chosen timeline month into sight, loading pages until it is there.
+ /// Brings the first sequence of the chosen timeline month into sight once, loading pages until it is there.
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();