Add list count to user preferences cookie (#4637)

I think it's fair to assume that the user wants to set this as a preference and it fixes #4592.
This commit is contained in:
d11n 2023-02-15 03:04:17 +01:00 committed by GitHub
parent 87eef72289
commit cc9c63c33e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -50,11 +50,12 @@ namespace BTCPayServer
{
model.SearchTerm = section.SearchTerm;
model.TimezoneOffset = section.TimezoneOffset ?? 0;
model.Count = section.Count ?? BasePagingViewModel.CountDefault;
}
}
else
{
prop.SetValue(prefCookie, new ListQueryDataHolder(model.SearchTerm, model.TimezoneOffset));
prop.SetValue(prefCookie, new ListQueryDataHolder(model.SearchTerm, model.TimezoneOffset, model.Count));
ctrl.Response.Cookies.Append(nameof(UserPrefsCookie), JsonConvert.SerializeObject(prefCookie));
}

View file

@ -14,13 +14,15 @@ namespace BTCPayServer
{
public ListQueryDataHolder() { }
public ListQueryDataHolder(string searchTerm, int? timezoneOffset)
public ListQueryDataHolder(string searchTerm, int? timezoneOffset, int? count)
{
SearchTerm = searchTerm;
TimezoneOffset = timezoneOffset;
Count = count;
}
public int? TimezoneOffset { get; set; }
public string SearchTerm { get; set; }
public int? Count { get; set; }
}
}

View file

@ -5,8 +5,10 @@ namespace BTCPayServer.Models
{
public abstract class BasePagingViewModel
{
public const int CountDefault = 50;
public int Skip { get; set; } = 0;
public int Count { get; set; } = 50;
public int Count { get; set; } = CountDefault;
public int? Total { get; set; }
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string SearchTerm { get; set; }