From 0dbacc81eaa13cec0c0f287c707e88334aed1f70 Mon Sep 17 00:00:00 2001 From: Haruka <96925398+nakoyasha@users.noreply.github.com> Date: Tue, 2 May 2023 15:03:16 +0300 Subject: [PATCH] Fetch selectable channel list from RDHT (#142) --- Bloxstrap/App.xaml.cs | 5 ++++- Bloxstrap/DeployHelper.cs | 28 ++++++++++++++++++++++++++++ Bloxstrap/Deployment.cs | 17 ++++++----------- 3 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 Bloxstrap/DeployHelper.cs diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 86d5c1a..6554e4f 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -109,7 +109,7 @@ namespace Bloxstrap Terminate(Bootstrapper.ERROR_INSTALL_FAILURE); } - protected override void OnStartup(StartupEventArgs e) + protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); @@ -157,6 +157,9 @@ namespace Bloxstrap } } + // this looks like the most fitting place for it + await Deployment.Initialize(); + // so this needs to be here because winforms moment // onclick events will not fire unless this is defined here in the main thread so uhhhhh // we'll show the icon if we're launching roblox since we're likely gonna be showing a diff --git a/Bloxstrap/DeployHelper.cs b/Bloxstrap/DeployHelper.cs new file mode 100644 index 0000000..8261163 --- /dev/null +++ b/Bloxstrap/DeployHelper.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using Newtonsoft.Json; +using System.Text.Json; + +namespace Bloxstrap +{ + internal class DeployHelper + { + public static readonly string ChannelURL = "https://raw.githubusercontent.com/bluepilledgreat/Roblox-DeployHistory-Tracker/main/ChannelsActive.json"; + private static HttpClient HttpClient = new HttpClient(); + + public static async Task> GetChannels() + { + App.Logger.WriteLine($"[DeployHelper::GetChannels] Trying to get currently active channels from {ChannelURL}"); + + var Response = await HttpClient.GetAsync(ChannelURL); + var JSON = await Response.Content.ReadAsStringAsync(); + + var Channels = JsonConvert.DeserializeObject>(JSON); + + return Channels; + } + } +} diff --git a/Bloxstrap/Deployment.cs b/Bloxstrap/Deployment.cs index c46d618..5a10688 100644 --- a/Bloxstrap/Deployment.cs +++ b/Bloxstrap/Deployment.cs @@ -59,19 +59,14 @@ namespace Bloxstrap } // most commonly used/interesting channels - public static readonly List SelectableChannels = new() - { - "LIVE", - "ZWinPlayer64", - "ZFlag", - "ZNext", - "ZCanary", - "ZIntegration", - "ZAvatarTeam", - "ZSocialTeam" - }; + public static List SelectableChannels = null; #endregion + public static async Task Initialize() + { + SelectableChannels = await DeployHelper.GetChannels(); + } + public static string GetLocation(string resource, string? channel = null) { if (string.IsNullOrEmpty(channel))