mirror of
https://github.com/ppy/osu
synced 2025-02-06 13:22:14 +00:00
Merge pull request #22085 from peppy/fix-channel-init-request-pile-up
Fix retry loop for channel initialisation resulting in request pile-up
This commit is contained in:
commit
426ac5ee54
@ -71,7 +71,6 @@ namespace osu.Game.Online.Chat
|
||||
private UserLookupCache users { get; set; }
|
||||
|
||||
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||
private bool channelsInitialised;
|
||||
private ScheduledDelegate scheduledAck;
|
||||
|
||||
private long? lastSilenceMessageId;
|
||||
@ -95,15 +94,7 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
connector.NewMessages += msgs => Schedule(() => addMessages(msgs));
|
||||
|
||||
connector.PresenceReceived += () => Schedule(() =>
|
||||
{
|
||||
if (!channelsInitialised)
|
||||
{
|
||||
channelsInitialised = true;
|
||||
// we want this to run after the first presence so we can see if the user is in any channels already.
|
||||
initializeChannels();
|
||||
}
|
||||
});
|
||||
connector.PresenceReceived += () => Schedule(initializeChannels);
|
||||
|
||||
connector.Start();
|
||||
|
||||
@ -335,6 +326,11 @@ namespace osu.Game.Online.Chat
|
||||
|
||||
private void initializeChannels()
|
||||
{
|
||||
// This request is self-retrying until it succeeds.
|
||||
// To avoid requests piling up when not logged in (ie. API is unavailable) exit early.
|
||||
if (!api.IsLoggedIn)
|
||||
return;
|
||||
|
||||
var req = new ListChannelsRequest();
|
||||
|
||||
bool joinDefaults = JoinedChannels.Count == 0;
|
||||
@ -350,10 +346,11 @@ namespace osu.Game.Online.Chat
|
||||
joinChannel(ch);
|
||||
}
|
||||
};
|
||||
|
||||
req.Failure += error =>
|
||||
{
|
||||
Logger.Error(error, "Fetching channel list failed");
|
||||
initializeChannels();
|
||||
Scheduler.AddDelayed(initializeChannels, 60000);
|
||||
};
|
||||
|
||||
api.Queue(req);
|
||||
|
Loading…
Reference in New Issue
Block a user