Fix nullref in case of successfull request but no backgrounds available

This commit is contained in:
Max Hübner 2020-10-30 17:57:29 +01:00
parent 0b46c19b23
commit 51a58269ad
1 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ private void load(SessionStatics sessionStatics, IAPIProvider api)
request.Success += response =>
{
cachedResponse.Value = response;
current = RNG.Next(0, cachedResponse.Value.Backgrounds.Count);
current = RNG.Next(0, response.Backgrounds?.Count ?? 0);
};
api.PerformAsync(request);
@ -41,7 +41,7 @@ private void load(SessionStatics sessionStatics, IAPIProvider api)
public SeasonalBackground LoadBackground()
{
var backgrounds = cachedResponse.Value.Backgrounds;
if (!backgrounds.Any()) return null;
if (backgrounds == null || !backgrounds.Any()) return null;
current = (current + 1) % backgrounds.Count;
string url = backgrounds[current].Url;