protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback) { if (Scope == BeatmapLeaderboardScope.Local) { Scores = scoreManager.QueryScores(s => s.Beatmap.ID == Beatmap.ID).ToArray(); PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; return(null); } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.Unavailable; return(null); } if (Scope != BeatmapLeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { PlaceholderState = PlaceholderState.NotSupporter; return(null); } var req = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); req.Success += r => scoresCallback?.Invoke(r.Scores); return(req); }
private void updateScores() { getScoresRequest?.Cancel(); getScoresRequest = null; pendingUpdateScores?.Cancel(); pendingUpdateScores = Schedule(() => { if (Scope == LeaderboardScope.Local) { // TODO: get local scores from wherever here. PlaceholderState = PlaceholderState.NoScores; return; } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.Unavailable; return; } if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { PlaceholderState = PlaceholderState.NotSupporter; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); getScoresRequest.Success += r => Schedule(() => { Scores = r.Scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; }); getScoresRequest.Failure += e => Schedule(() => { if (e is OperationCanceledException) { return; } PlaceholderState = PlaceholderState.NetworkFailure; }); api.Queue(getScoresRequest); }); }
protected void UpdateScores() { // don't display any scores or placeholder until the first Scores_Set has been called. // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished. if (!scoresLoadedOnce) { return; } getScoresRequest?.Cancel(); getScoresRequest = null; pendingUpdateScores?.Cancel(); pendingUpdateScores = Schedule(() => { if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); getScoresRequest = FetchScores(scores => Schedule(() => { Scores = scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; })); if (getScoresRequest == null) { return; } getScoresRequest.Failure += e => Schedule(() => { if (e is OperationCanceledException) { return; } PlaceholderState = PlaceholderState.NetworkFailure; }); api.Queue(getScoresRequest); }); }
private void updateScores() { getScoresRequest?.Cancel(); getScoresRequest = null; Scores = null; if (Scope == LeaderboardScope.Local) { // TODO: get local scores from wherever here. PlaceholderState = PlaceholderState.NoScores; return; } if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.NetworkFailure; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { loading.Hide(); PlaceholderState = PlaceholderState.NotSupporter; return; } getScoresRequest = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope); getScoresRequest.Success += r => { Scores = r.Scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; }; getScoresRequest.Failure += onUpdateFailed; api.Queue(getScoresRequest); }
private void updateScores() { // don't display any scores or placeholder until the first Scores_Set has been called. // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished. if (!scoresLoadedOnce) { return; } getScoresRequest?.Cancel(); getScoresRequest = null; pendingUpdateScores?.Cancel(); pendingUpdateScores = Schedule(() => { if (Scope == LeaderboardScope.Local) { // TODO: get local scores from wherever here. PlaceholderState = PlaceholderState.NoScores; return; } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.Unavailable; return; } if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { PlaceholderState = PlaceholderState.NotSupporter; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); getScoresRequest.Success += r => Schedule(() => { Scores = r.Scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; }); getScoresRequest.Failure += e => Schedule(() => { if (e is OperationCanceledException) { return; } PlaceholderState = PlaceholderState.NetworkFailure; }); api.Queue(getScoresRequest); }); }