Path: redb-tsak/src/redb.Tsak.Web/Services/QueryState.cs Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Web/Services/QueryState.cs ---- using Microsoft.AspNetCore.Components; namespace redb.Tsak.Web.Services; /// /// A page's meaningful state (time range, filters, sub-tab) kept in the address query, so that it survives a reload, /// a shared link and a change of node through the switcher (which keeps the query). The address is replaced, not /// pushed: changing a filter does not add a step to the browser history. /// public static class QueryState { /// Writes under ; an empty value or the default removes the parameter. public static void Set(NavigationManager nav, string name, string? value, string? defaultValue = null) { ArgumentNullException.ThrowIfNull(nav); var keep = string.IsNullOrEmpty(value) || value == defaultValue ? null : value; var target = nav.GetUriWithQueryParameter(name, keep); if (target != nav.Uri) nav.NavigateTo(target, replace: true); } /// Writes several parameters at once (one address change); empty values remove theirs. public static void Set(NavigationManager nav, IReadOnlyDictionary values) { ArgumentNullException.ThrowIfNull(nav); var parameters = values.ToDictionary(kv => kv.Key, kv => (object?)(string.IsNullOrEmpty(kv.Value) ? null : kv.Value)); var target = nav.GetUriWithQueryParameters(parameters); if (target != nav.Uri) nav.NavigateTo(target, replace: true); } /// One of (any case, returned as listed), else . public static string OneOf(string? value, IReadOnlyList allowed, string fallback) => allowed.FirstOrDefault(a => string.Equals(a, value, StringComparison.OrdinalIgnoreCase)) ?? fallback; /// One of parsed from , else . public static int OneOf(string? value, IReadOnlyList allowed, int fallback) => int.TryParse(value, out var n) && allowed.Contains(n) ? n : fallback; }