mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Fix adjacent day separators potentially being left behind after pending message resolution
This commit is contained in:
parent
76bb529cfa
commit
5467097387
@ -141,27 +141,15 @@ namespace osu.Game.Overlays.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
var staleMessages = chatLines.Where(c => c.LifetimeEnd == double.MaxValue).ToArray();
|
||||||
|
|
||||||
int count = staleMessages.Length - Channel.MAX_HISTORY;
|
int count = staleMessages.Length - Channel.MAX_HISTORY;
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
void expireAndAdjustScroll(Drawable d)
|
|
||||||
{
|
|
||||||
scroll.OffsetScrollPosition(-d.DrawHeight);
|
|
||||||
d.Expire();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
expireAndAdjustScroll(staleMessages[i]);
|
expireAndAdjustScroll(staleMessages[i]);
|
||||||
|
|
||||||
// remove all adjacent day separators after stale message removal
|
removeAdjacentDaySeparators();
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// due to the scroll adjusts from old messages removal above, a scroll-to-end must be enforced,
|
// 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.Remove(ds, true);
|
||||||
|
|
||||||
ChatLineFlow.Add(CreateDaySeparator(message.Timestamp));
|
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(() =>
|
private void messageRemoved(Message removed) => Schedule(() =>
|
||||||
{
|
{
|
||||||
chatLines.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire();
|
chatLines.FirstOrDefault(c => c.Message == removed)?.FadeColour(Color4.Red, 400).FadeOut(600).Expire();
|
||||||
|
Loading…
Reference in New Issue
Block a user