Fetch selectable channel list from RDHT (#142)

This commit is contained in:
Haruka 2023-05-02 15:03:16 +03:00
parent 0fc7b56458
commit 0dbacc81ea
3 changed files with 38 additions and 12 deletions

View File

@ -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

28
Bloxstrap/DeployHelper.cs Normal file
View File

@ -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<List<string>> 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<List<string>>(JSON);
return Channels;
}
}
}

View File

@ -59,19 +59,14 @@ namespace Bloxstrap
}
// most commonly used/interesting channels
public static readonly List<string> SelectableChannels = new()
{
"LIVE",
"ZWinPlayer64",
"ZFlag",
"ZNext",
"ZCanary",
"ZIntegration",
"ZAvatarTeam",
"ZSocialTeam"
};
public static List<string> 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))