feature: Phase 18.6 Track A — public Settings menu + streaming-quality toggle
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using DeepDrftPublic.Client.Common;
|
||||
|
||||
namespace DeepDrftPublic.Client.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Shared cookie contract for the public-site settings seam (Phase 18 wave 18.6), the analogue of
|
||||
/// <see cref="DarkModeServiceBase"/>. Holds the cookie names and the (de)serialization for each preference
|
||||
/// so the server prerender-read service and the client cookie-write service agree on one wire format —
|
||||
/// the load-bearing reason this is shared rather than duplicated. Each new preference adds its cookie name
|
||||
/// and a parse/format pair here, keeping the round-trip in one place.
|
||||
/// </summary>
|
||||
public abstract class SettingsServiceBase
|
||||
{
|
||||
protected const string StreamQualityCookieName = "streamQuality";
|
||||
|
||||
/// <summary>
|
||||
/// Parses the <c>streamQuality</c> cookie value into <see cref="StreamQuality"/>, defaulting to
|
||||
/// <see cref="StreamQuality.LowData"/> (the OQ2 default) for an absent, empty, or unrecognized value so
|
||||
/// a missing/garbled cookie never produces a surprising preference.
|
||||
/// </summary>
|
||||
protected static StreamQuality ParseStreamQuality(string? cookieValue) =>
|
||||
Enum.TryParse<StreamQuality>(cookieValue, ignoreCase: true, out var parsed)
|
||||
? parsed
|
||||
: StreamQuality.LowData;
|
||||
|
||||
/// <summary>Formats a <see cref="StreamQuality"/> for cookie storage (round-trips with <see cref="ParseStreamQuality"/>).</summary>
|
||||
protected static string FormatStreamQuality(StreamQuality quality) => quality.ToString();
|
||||
}
|
||||
Reference in New Issue
Block a user