Skip to content

Commit be0a115

Browse files
committed
Added utility function to fetch the versions list from BeatMods.
1 parent 2eae530 commit be0a115

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

ModAssistant/Classes/Utils.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,14 @@ public static string GetVersion()
275275
var strlen = reader.ReadInt32();
276276
var strbytes = reader.ReadBytes(strlen);
277277

278-
var version = Encoding.UTF8.GetString(strbytes);
278+
// TODO: should cache this
279+
public static async Task<List<string>> GetVersionsList()
280+
{
281+
var resp = await HttpClient.GetAsync(Utils.Constants.BeatModsVersions);
282+
var body = await resp.Content.ReadAsStringAsync();
283+
List<string> versions = JsonSerializer.Deserialize<string[]>(body).ToList();
279284

280-
//There is one version ending in "p1" on BeatMods
281-
var filteredVersionMatch = Regex.Match(version, @"[\d]+.[\d]+.[\d]+(p1)?");
282-
return filteredVersionMatch.Success ? filteredVersionMatch.Value : version;
283-
}
285+
return versions;
284286
}
285287

286288
public static string GetOculusDir()

ModAssistant/MainWindow.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ private async void LoadVersionsAsync()
114114
{
115115
try
116116
{
117-
var resp = await HttpClient.GetAsync(Utils.Constants.BeatModsVersions);
117+
var versions = await Utils.GetVersionsList();
118+
119+
var resp = await HttpClient.GetAsync(Utils.Constants.BeatModsAlias);
118120
var body = await resp.Content.ReadAsStringAsync();
119121
List<string> versions = JsonSerializer.Deserialize<string[]>(body).ToList();
120122

0 commit comments

Comments
 (0)