misc: chore: Simplify ReleaseChannels creation

This commit is contained in:
GreemDev 2025-03-16 14:21:17 -05:00
parent 95fdc0ca24
commit 078909169d

View file

@ -49,23 +49,22 @@ namespace Ryujinx.Common
public static async Task<ReleaseChannels> GetReleaseChannelsAsync(HttpClient httpClient) public static async Task<ReleaseChannels> GetReleaseChannelsAsync(HttpClient httpClient)
{ {
ReleaseChannelPair releaseChannelPair = JsonHelper.Deserialize(await httpClient.GetStringAsync("https://ryujinx.app/api/release-channels"), ReleaseChannelPairContext.Default.ReleaseChannelPair); ReleaseChannelPair releaseChannelPair = JsonHelper.Deserialize(await httpClient.GetStringAsync("https://ryujinx.app/api/release-channels"), ReleaseChannelPairContext.Default.ReleaseChannelPair);
return ReleaseChannels.Create(releaseChannelPair); return new ReleaseChannels(releaseChannelPair);
} }
} }
public struct ReleaseChannels public readonly struct ReleaseChannels
{ {
internal static ReleaseChannels Create(ReleaseChannelPair channelPair) => internal ReleaseChannels(ReleaseChannelPair channelPair)
new()
{ {
Stable = new Channel(channelPair.Stable), Stable = new Channel(channelPair.Stable);
Canary = new Channel(channelPair.Canary) Canary = new Channel(channelPair.Canary);
}; }
public Channel Stable { get; init; } public readonly Channel Stable;
public Channel Canary { get; init; } public readonly Channel Canary;
public struct Channel public readonly struct Channel
{ {
public Channel(string raw) public Channel(string raw)
{ {
@ -74,8 +73,8 @@ namespace Ryujinx.Common
Repo = parts[1]; Repo = parts[1];
} }
public string Owner; public readonly string Owner;
public string Repo; public readonly string Repo;
public override string ToString() => $"{Owner}/{Repo}"; public override string ToString() => $"{Owner}/{Repo}";