1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Fix adjacent day separators potentially being left behind after pending message resolution

This commit is contained in:
Dean Herbert 2022-11-23 18:49:51 +09:00
parent 76bb529cfa
commit 5467097387

View File

@ -141,27 +141,15 @@ namespace osu.Game.Overlays.Chat
}
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
int count = staleMessages.Length - Channel.MAX_HISTORY;
if (count > 0)
{
void expireAndAdjustScroll(Drawable d)
{
scroll.OffsetScrollPosition(-d.DrawHeight);
d.Expire();
}
for (int i = 0; i < count; i++)
expireAndAdjustScroll(staleMessages[i]);
// remove all adjacent day separators after stale message removal
for (int i = 0; i < ChatLineFlow.Count - 1; i++)
{
if (!(ChatLineFlow[i] is DaySeparator)) break;
if (!(ChatLineFlow[i + 1] is DaySeparator)) break;
expireAndAdjustScroll(ChatLineFlow[i]);
}
removeAdjacentDaySeparators();
}
// due to the scroll adjusts from old messages removal above, a scroll-to-end must be enforced,
@ -199,9 +187,29 @@ namespace osu.Game.Overlays.Chat
ChatLineFlow.Remove(ds, true);
ChatLineFlow.Add(CreateDaySeparator(message.Timestamp));
removeAdjacentDaySeparators();
}
}
private void removeAdjacentDaySeparators()
{
// remove all adjacent day separators after stale message removal
for (int i = 0; i < ChatLineFlow.Count - 1; i++)
{
if (!(ChatLineFlow[i] is DaySeparator)) break;
if (!(ChatLineFlow[i + 1] is DaySeparator)) break;
expireAndAdjustScroll(ChatLineFlow[i]);
}
}
private void expireAndAdjustScroll(Drawable d)
{
scroll.OffsetScrollPosition(-d.DrawHeight);
d.Expire();
}
private void messageRemoved(Message removed) => Schedule(() =>
{
chatLines.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire();