namespace OpenNest.Data;
///
/// Browse state for Nest > Drawing Sets: the requested search, archived toggle, sort and
/// page, and the last page applied. Paging, superseding and disposal follow
/// . Call from one thread (the UI thread).
///
public sealed class DrawingSetBrowseSession : BrowseSession
{
private readonly IDrawingSetStore _sets;
public DrawingSetBrowseSession(IDrawingSetStore sets, int pageSize = DrawingSetQuery.DefaultLimit)
: base(pageSize, DrawingSetQuery.MaxLimit, DrawingSetSortField.SavedAt)
{
ArgumentNullException.ThrowIfNull(sets);
_sets = sets;
}
/// True when archived sets are listed with the active ones.
public bool IncludeArchived { get; private set; }
///
public override string Summary =>
PageSummary("sets", Search.Length > 0 ? "No sets match the search." : "No drawing sets yet. Choose New Set to make one.");
/// Lists or hides archived sets and returns to the first page.
public Task SetIncludeArchivedAsync(bool includeArchived)
{
IncludeArchived = includeArchived;
return FirstPageAsync();
}
protected override Task QueryAsync(CancellationToken cancellationToken) =>
_sets.QueryAsync(
new DrawingSetQuery
{
Search = Search,
IncludeArchived = IncludeArchived,
Sort = Sort,
Descending = Descending,
Offset = Offset,
Limit = PageSize,
},
cancellationToken);
}