Skip to content

Commit

Permalink
Fix retry loop for channel initialisation resulting in request pile-up
Browse files Browse the repository at this point in the history
Closes ppy#22060.
  • Loading branch information
peppy committed Jan 9, 2023
1 parent d05e84b commit 13c3d2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion osu.Game/Online/Chat/ChannelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ private void addMessages(List<Message> messages)

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;
Expand All @@ -350,10 +355,11 @@ private void initializeChannels()
joinChannel(ch);
}
};

req.Failure += error =>
{
Logger.Error(error, "Fetching channel list failed");
initializeChannels();
Scheduler.AddDelayed(initializeChannels, 60000);
};

api.Queue(req);
Expand Down

0 comments on commit 13c3d2c

Please sign in to comment.