Merge pull request #3161 from peppy/scroll-chat-on-message

Scroll chat to end of buffer when posting a new message
This commit is contained in:
Dan Balasescu 2018-08-04 00:21:17 +09:00 committed by GitHub
commit c3060e18a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -6,7 +6,7 @@
namespace osu.Game.Online.Chat
{
public class InfoMessage : Message
public class InfoMessage : LocalMessage
{
private static int infoID = -1;

View File

@ -3,7 +3,7 @@
namespace osu.Game.Online.Chat
{
public class LocalEchoMessage : Message
public class LocalEchoMessage : LocalMessage
{
public LocalEchoMessage() : base(null)
{

View File

@ -0,0 +1,16 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Online.Chat
{
/// <summary>
/// A message which is generated and displayed locally.
/// </summary>
public class LocalMessage : Message
{
protected LocalMessage(long? id)
: base(id)
{
}
}
}

View File

@ -85,7 +85,7 @@ private void newMessagesArrived(IEnumerable<Message> newMessages)
if (!IsLoaded) return;
if (scroll.IsScrolledToEnd(10) || !flow.Children.Any())
if (scroll.IsScrolledToEnd(10) || !flow.Children.Any() || newMessages.Any(m => m is LocalMessage))
scrollToEnd();
var staleMessages = flow.Children.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();