mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 07:32:55 +08:00
Merge pull request #8893 from peppy/reduce-initial-channel-load-overhead
Reduce initial channel load overhead by only loading history on active channel
This commit is contained in:
commit
c3ef1d3170
@ -93,6 +93,12 @@ namespace osu.Game.Online.Chat
|
||||
{
|
||||
if (!(e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel))
|
||||
JoinChannel(e.NewValue);
|
||||
|
||||
if (e.NewValue?.MessagesLoaded == false)
|
||||
{
|
||||
// let's fetch a small number of messages to bring us up-to-date with the backlog.
|
||||
fetchInitalMessages(e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -375,12 +381,6 @@ namespace osu.Game.Online.Chat
|
||||
if (CurrentChannel.Value == null)
|
||||
CurrentChannel.Value = channel;
|
||||
|
||||
if (!channel.MessagesLoaded)
|
||||
{
|
||||
// let's fetch a small number of messages to bring us up-to-date with the backlog.
|
||||
fetchInitalMessages(channel);
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,14 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
private void newMessagesArrived(IEnumerable<Message> newMessages)
|
||||
{
|
||||
if (newMessages.Min(m => m.Id) < chatLines.Max(c => c.Message.Id))
|
||||
{
|
||||
// there is a case (on initial population) that we may receive past messages and need to reorder.
|
||||
// easiest way is to just combine messages and recreate drawables (less worrying about day separators etc.)
|
||||
newMessages = newMessages.Concat(chatLines.Select(c => c.Message)).OrderBy(m => m.Id).ToList();
|
||||
ChatLineFlow.Clear();
|
||||
}
|
||||
|
||||
bool shouldScrollToEnd = scroll.IsScrolledToEnd(10) || !chatLines.Any() || newMessages.Any(m => m is LocalMessage);
|
||||
|
||||
// Add up to last Channel.MAX_HISTORY messages
|
||||
|
Loading…
Reference in New Issue
Block a user