Skip to content

Commit

Permalink
Added fallback for retrieving current champion and bumped version
Browse files Browse the repository at this point in the history
- Implemented a fallback mechanism to retrieve the current champion if the initial method fails
- Version bumped
  • Loading branch information
Rokuazery committed May 10, 2023
1 parent 3b03f84 commit ad7eb4a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions LoL Assist/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,11 @@ public async void LoLMonitor()
private async void ReImport() => await Task.Run(async () => {
var currentChampion = (await LCUWrapper.GetCurrentChampionIdAsync(SummonerId)).ToString();
currentChampion = Converter.ChampionKeyToName(currentChampion);

// Fallback if the mode doesn't support /lol-champ-select-legacy/v1/session
if (string.IsNullOrEmpty(currentChampion))
currentChampion = await LCUWrapper.GetCurrentChampionAsyncV2();

ImportBuilds(currentChampion, true);
});

Expand Down
6 changes: 6 additions & 0 deletions LoLA/LoLA/Networking/LCU/Events/ChampionMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ private async void championMonitor()
var phase = await LCUWrapper.GetGamePhaseAsync();
if (phase == Phase.ChampSelect)
{

var currentChampion = (await LCUWrapper.GetCurrentChampionIdAsync(SummonerId)).ToString();
currentChampion = Converter.ChampionKeyToName(currentChampion);

// Fallback if the mode doesn't support /lol-champ-select-legacy/v1/session
if (string.IsNullOrEmpty(currentChampion))
currentChampion = await LCUWrapper.GetCurrentChampionAsyncV2();

if (LastChampion != currentChampion)
{
LastChampion = currentChampion;
Expand Down
2 changes: 1 addition & 1 deletion LoLA/LoLA/Networking/LCU/LCUWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static async Task<JObject> GetCurrentSessionAsync()
if (!await InitAsync())
return null;

var currentSessionJson = await GetDataRequestAsync(RequestMethod.GET, "/lol-champ-select/v1/session");
var currentSessionJson = await GetDataRequestAsync(RequestMethod.GET, "/lol-champ-select-legacy/v1/session");

if (string.IsNullOrEmpty(currentSessionJson)) return null;

Expand Down
4 changes: 2 additions & 2 deletions Version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
2.0.0.8
2.0.0.6
2.0.1.2
2.0.1.0

0 comments on commit ad7eb4a

Please sign in to comment.