1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Fix initial requests of channel mesages not being performed

fetchReq was being set even for initial lookups, which caused only one to run, and subsequent requests to be excessive to try and catch up.
This commit is contained in:
Dean Herbert 2017-05-16 15:56:53 +09:00
parent 0e45277416
commit f0ea445e46

View File

@ -245,7 +245,7 @@ namespace osu.Game.Overlays
addChannel(channels.Find(c => c.Name == @"#lobby"));
});
messageRequest = Scheduler.AddDelayed(() => fetchNewMessages(), 1000, true);
messageRequest = Scheduler.AddDelayed(fetchNewMessages, 1000, true);
};
api.Queue(req);
@ -289,17 +289,34 @@ namespace osu.Game.Overlays
channelTabs.AddItem(channel);
// we need to get a good number of messages initially for each channel we care about.
fetchNewMessages(channel);
fetchInitialMessages(channel);
if (CurrentChannel == null)
CurrentChannel = channel;
}
private void fetchNewMessages(Channel specificChannel = null)
private void fetchInitialMessages(Channel channel)
{
var req = new GetMessagesRequest(new List<Channel> { channel }, null);
req.Success += delegate (List<Message> messages)
{
channel.AddNewMessages(messages.ToArray());
Debug.Write("success!");
};
req.Failure += delegate
{
Debug.Write("failure!");
};
api.Queue(req);
}
private void fetchNewMessages()
{
if (fetchReq != null) return;
fetchReq = new GetMessagesRequest(specificChannel != null ? new List<Channel> { specificChannel } : careChannels, lastMessageId);
fetchReq = new GetMessagesRequest(careChannels, lastMessageId);
fetchReq.Success += delegate (List<Message> messages)
{
var ids = messages.Where(m => m.TargetType == TargetType.Channel).Select(m => m.TargetId).Distinct();