mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 19:05:37 +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))
|
if (!(e.NewValue is ChannelSelectorTabItem.ChannelSelectorTabChannel))
|
||||||
JoinChannel(e.NewValue);
|
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>
|
/// <summary>
|
||||||
@ -375,12 +381,6 @@ namespace osu.Game.Online.Chat
|
|||||||
if (CurrentChannel.Value == null)
|
if (CurrentChannel.Value == null)
|
||||||
CurrentChannel.Value = channel;
|
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;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,14 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
private void newMessagesArrived(IEnumerable<Message> newMessages)
|
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);
|
bool shouldScrollToEnd = scroll.IsScrolledToEnd(10) || !chatLines.Any() || newMessages.Any(m => m is LocalMessage);
|
||||||
|
|
||||||
// Add up to last Channel.MAX_HISTORY messages
|
// Add up to last Channel.MAX_HISTORY messages
|
||||||
|
Loading…
Reference in New Issue
Block a user