Skip to content

Commit

Permalink
* Fix a small paint bug when two messages are received at the same time.
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed May 31, 2024
1 parent 33a104f commit ffd77d3
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions src/windows/MessageList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4243,21 +4243,9 @@ void MessageList::AddMessageInternal(const Message& msg, bool toStart, bool upda

int oldHeight = 0;

// If the message has a nonce, then delete that.
bool bDeletedNonce = false;
RECT nonceRect = {};
for (auto iter = m_messages.rbegin(); iter != m_messages.rend(); ++iter)
{
if (iter->m_msg.m_snowflake == msg.m_anchor)
{
// delete it!
oldHeight = iter->m_height;
nonceRect = iter->m_rect;
m_messages.erase(--(iter.base())); // sucks
bDeletedNonce = true;
break;
}
}
// If the message has a nonce, then delete it.
if (msg.m_anchor)
DeleteMessage(msg.m_anchor);

Snowflake prevAuthor = Snowflake(-1);
time_t prevDate = 0;
Expand Down Expand Up @@ -4308,32 +4296,14 @@ void MessageList::AddMessageInternal(const Message& msg, bool toStart, bool upda
RECT rcClient{};
GetClientRect(m_hwnd, &rcClient);

int offsetY = 0;
if (bDeletedNonce) {
if (toStart)
offsetY = -(nonceRect.bottom - rcClient.top);
else
offsetY = rcClient.bottom - nonceRect.top;
}

UpdateScrollBar(mi.m_height - oldHeight, mi.m_height - oldHeight, toStart, true, offsetY, true);
UpdateScrollBar(mi.m_height - oldHeight, mi.m_height - oldHeight, toStart, true, 0, true);

bool needUpdateAboveMessage = GetLocalSettings()->GetMessageStyle() == MS_3DFACE;
if (needUpdateAboveMessage && mi.m_placeInChain != 0) {
RECT rcUpdate = rcClient;
rcUpdate.bottom -= offsetY;
rcUpdate.top = rcUpdate.bottom - 2;
InvalidateRect(m_hwnd, &rcUpdate, FALSE);
}

if (bDeletedNonce)
{
// in case the message shrunk in size
nonceRect.top += oldHeight - mi.m_height;

// do it better
InvalidateRect(m_hwnd, &nonceRect, false);
}
}

void MessageList::UpdateAllowDrop()
Expand Down

0 comments on commit ffd77d3

Please sign in to comment.