mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 01:42:54 +08:00
Fix some web requests being run after disposal of their owner
This commit is contained in:
parent
b0f9c0f6f0
commit
923acfbeaf
@ -62,7 +62,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
getScoresRequest = new GetScoresRequest(beatmap, beatmap.Ruleset);
|
||||||
getScoresRequest.Success += r => Scores = r.Scores;
|
getScoresRequest.Success += r => Schedule(() => Scores = r.Scores);
|
||||||
api.Queue(getScoresRequest);
|
api.Queue(getScoresRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|||||||
public class PaginatedBeatmapContainer : PaginatedContainer
|
public class PaginatedBeatmapContainer : PaginatedContainer
|
||||||
{
|
{
|
||||||
private const float panel_padding = 10f;
|
private const float panel_padding = 10f;
|
||||||
|
|
||||||
private readonly BeatmapSetType type;
|
private readonly BeatmapSetType type;
|
||||||
|
private GetUserBeatmapsRequest request;
|
||||||
|
|
||||||
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
|
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
|
||||||
: base(user, header, missing)
|
: base(user, header, missing)
|
||||||
@ -31,9 +31,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|||||||
{
|
{
|
||||||
base.ShowMore();
|
base.ShowMore();
|
||||||
|
|
||||||
var req = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
|
request = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
|
||||||
|
request.Success += sets => Schedule(() =>
|
||||||
req.Success += sets =>
|
|
||||||
{
|
{
|
||||||
ShowMoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0);
|
ShowMoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0);
|
||||||
ShowMoreLoading.Hide();
|
ShowMoreLoading.Hide();
|
||||||
@ -52,9 +51,15 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|||||||
var panel = new DirectGridPanel(s.ToBeatmapSet(Rulesets));
|
var panel = new DirectGridPanel(s.ToBeatmapSet(Rulesets));
|
||||||
ItemsContainer.Add(panel);
|
ItemsContainer.Add(panel);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
Api.Queue(req);
|
Api.Queue(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
request?.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer
|
public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer
|
||||||
{
|
{
|
||||||
|
private GetUserMostPlayedBeatmapsRequest request;
|
||||||
|
|
||||||
public PaginatedMostPlayedBeatmapContainer(Bindable<User> user)
|
public PaginatedMostPlayedBeatmapContainer(Bindable<User> user)
|
||||||
:base(user, "Most Played Beatmaps", "No records. :(")
|
:base(user, "Most Played Beatmaps", "No records. :(")
|
||||||
{
|
{
|
||||||
@ -24,9 +26,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
base.ShowMore();
|
base.ShowMore();
|
||||||
|
|
||||||
var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
request = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||||
|
request.Success += beatmaps => Schedule(() =>
|
||||||
req.Success += beatmaps =>
|
|
||||||
{
|
{
|
||||||
ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
|
ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
|
||||||
ShowMoreLoading.Hide();
|
ShowMoreLoading.Hide();
|
||||||
@ -43,9 +44,16 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
ItemsContainer.Add(new DrawableMostPlayedRow(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount));
|
ItemsContainer.Add(new DrawableMostPlayedRow(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount));
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
Api.Queue(req);
|
Api.Queue(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
request?.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
protected readonly Bindable<User> User = new Bindable<User>();
|
protected readonly Bindable<User> User = new Bindable<User>();
|
||||||
|
|
||||||
protected APIAccess Api;
|
protected APIAccess Api;
|
||||||
|
protected APIRequest RetrievalRequest;
|
||||||
protected RulesetStore Rulesets;
|
protected RulesetStore Rulesets;
|
||||||
|
|
||||||
public PaginatedContainer(Bindable<User> user, string header, string missing)
|
public PaginatedContainer(Bindable<User> user, string header, string missing)
|
||||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
{
|
{
|
||||||
private readonly bool includeWeight;
|
private readonly bool includeWeight;
|
||||||
private readonly ScoreType type;
|
private readonly ScoreType type;
|
||||||
|
private GetUserScoresRequest request;
|
||||||
|
|
||||||
public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string header, string missing, bool includeWeight = false)
|
public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string header, string missing, bool includeWeight = false)
|
||||||
: base(user, header, missing)
|
: base(user, header, missing)
|
||||||
@ -32,9 +33,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
{
|
{
|
||||||
base.ShowMore();
|
base.ShowMore();
|
||||||
|
|
||||||
var req = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
|
request = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
|
||||||
|
request.Success += scores => Schedule(() =>
|
||||||
req.Success += scores =>
|
|
||||||
{
|
{
|
||||||
foreach (var s in scores)
|
foreach (var s in scores)
|
||||||
s.ApplyRuleset(Rulesets.GetRuleset(s.OnlineRulesetID));
|
s.ApplyRuleset(Rulesets.GetRuleset(s.OnlineRulesetID));
|
||||||
@ -66,9 +66,15 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
|
|
||||||
ItemsContainer.Add(drawableScore);
|
ItemsContainer.Add(drawableScore);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
Api.Queue(req);
|
Api.Queue(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
request?.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
{
|
{
|
||||||
public class PaginatedRecentActivityContainer : PaginatedContainer
|
public class PaginatedRecentActivityContainer : PaginatedContainer
|
||||||
{
|
{
|
||||||
|
private GetUserRecentActivitiesRequest request;
|
||||||
|
|
||||||
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
|
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
|
||||||
: base(user, header, missing)
|
: base(user, header, missing)
|
||||||
{
|
{
|
||||||
@ -22,9 +24,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
{
|
{
|
||||||
base.ShowMore();
|
base.ShowMore();
|
||||||
|
|
||||||
var req = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
request = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||||
|
request.Success += activities => Schedule(() =>
|
||||||
req.Success += activities =>
|
|
||||||
{
|
{
|
||||||
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
|
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
|
||||||
ShowMoreLoading.Hide();
|
ShowMoreLoading.Hide();
|
||||||
@ -41,9 +42,15 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
{
|
{
|
||||||
ItemsContainer.Add(new DrawableRecentActivity(activity));
|
ItemsContainer.Add(new DrawableRecentActivity(activity));
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
Api.Queue(req);
|
Api.Queue(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
request?.Cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,15 @@ namespace osu.Game.Overlays
|
|||||||
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
|
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowUser(long userId)
|
public void ShowUser(long userId) => ShowUser(new User { Id = userId });
|
||||||
{
|
|
||||||
if (userId == Header.User.Id)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ShowUser(new User { Id = userId });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowUser(User user, bool fetchOnline = true)
|
public void ShowUser(User user, bool fetchOnline = true)
|
||||||
{
|
{
|
||||||
|
Show();
|
||||||
|
|
||||||
|
if (user.Id == Header?.User.Id)
|
||||||
|
return;
|
||||||
|
|
||||||
userReq?.Cancel();
|
userReq?.Cancel();
|
||||||
Clear();
|
Clear();
|
||||||
lastSection = null;
|
lastSection = null;
|
||||||
@ -97,6 +96,7 @@ namespace osu.Game.Overlays
|
|||||||
new BeatmapsSection(),
|
new BeatmapsSection(),
|
||||||
new KudosuSection()
|
new KudosuSection()
|
||||||
};
|
};
|
||||||
|
|
||||||
tabs = new ProfileTabControl
|
tabs = new ProfileTabControl
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
@ -161,7 +161,6 @@ namespace osu.Game.Overlays
|
|||||||
userLoadComplete(user);
|
userLoadComplete(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
Show();
|
|
||||||
sectionsContainer.ScrollToTop();
|
sectionsContainer.ScrollToTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user