private async Task LoadSession(Course course) { loading = true; currentCourse = course; currentChallenge.Answer = ""; StateHasChanged(); var session = await Http.GetFromJsonAsync <Session>($"duolingo/session/{course.FromLanguage}/{course.LearningLanguage}"); currentSession = session; challengeIndex = 0; currentChallenge = currentSession.Challenges[challengeIndex]; loading = false; StateHasChanged(); }
protected async Task Continue() { challengeIndex++; if (currentSession.Challenges.Length == challengeIndex) { loading = true; currentChallenge.Question = $"Gaining XP..."; currentChallenge.Answer = ""; StateHasChanged(); var result = await Http.GetFromJsonAsync <SessionOutcome>("duolingo/complete"); currentChallenge.Question = $"+{result.XpGain} XP, loading..."; await LoadSession(currentCourse); } else { currentChallenge = currentSession.Challenges[challengeIndex]; } }