mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 05:42:54 +08:00
Merge pull request #760 from peppy/message-fetch-fix
Fix initial requests of channel mesages not being performed
This commit is contained in:
commit
6cbaf1ba05
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user