MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / EditMessage

Method EditMessage

src/windows/MessageList.cpp:4716–4822  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4714}
4715
4716void MessageList::EditMessage(Snowflake msgId)
4717{
4718 MessageItem mi;
4719 mi.m_msg = GetMessageCache()->GetLoadedMessage(m_channelID, msgId);
4720 if (!mi.m_msg)
4721 return;
4722
4723 mi.Update(m_guildID);
4724
4725 LPCTSTR strAuth = mi.m_author;
4726 LPCTSTR strDate = mi.m_date;
4727 LPCTSTR strDateEdit = mi.m_dateEdited;
4728
4729 // measure the height
4730 int oldHeight = 0;
4731
4732 // If the message exists, then delete it.
4733 // TODO: Why are we doing this instead of just replacing the message in-place?
4734 bool bDeletedOldMsg = false;
4735 int placeInChainOld = -1;
4736 bool wasDateGap = false;
4737 RECT oldMsgRect = {};
4738 for (auto iter = m_messages.rbegin(); iter != m_messages.rend(); ++iter)
4739 {
4740 if (iter->m_msg->m_snowflake == msgId)
4741 {
4742 // delete it!
4743 oldHeight = iter->m_height;
4744 oldMsgRect = iter->m_rect;
4745 wasDateGap = iter->m_bIsDateGap;
4746 placeInChainOld = iter->m_placeInChain;
4747 auto msgIter = --(iter.base());
4748 m_messages.erase(msgIter); // sucks
4749 bDeletedOldMsg = true;
4750 break;
4751 }
4752 }
4753
4754 bool canInsert = false;
4755 bool firstTime = true;
4756 auto insertIter = m_messages.end();
4757 while (firstTime || insertIter != m_messages.end())
4758 {
4759 Snowflake thisSF = 0, nextSF = UINT64_MAX;
4760
4761 if (!firstTime)
4762 thisSF = insertIter->m_msg->m_snowflake;
4763
4764 auto nextiter = insertIter;
4765 if (firstTime)
4766 nextiter = m_messages.begin();
4767 else
4768 ++nextiter;
4769
4770 if (nextiter != m_messages.end()) {
4771 nextSF = nextiter->m_msg->m_snowflake;
4772 }
4773

Callers 1

WindowProcFunction · 0.45

Calls 10

GetMessageCacheFunction · 0.85
GetLocalSettingsFunction · 0.85
GetLoadedMessageMethod · 0.80
eraseMethod · 0.80
GetMessageStyleMethod · 0.80
UpdateMethod · 0.45
baseMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected