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

Method OpenInteractable

src/windows/MessageList.cpp:1399–1466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1397}
1398
1399void MessageList::OpenInteractable(InteractableItem* pItem, MessageItem* pMsg)
1400{
1401 switch (pItem->m_type)
1402 {
1403 case InteractableItem::EMBED_IMAGE: {
1404 std::string url = pItem->m_destination;
1405 std::string proxyUrl = pItem->m_proxyDest;
1406 std::string fileName = url;
1407 for (size_t i = fileName.size(); i != 0; i--) {
1408 if (fileName[i] == '/') {
1409 fileName = fileName.substr(i + 1);
1410 break;
1411 }
1412 }
1413 CreateImageViewer(
1414 proxyUrl,
1415 url,
1416 fileName,
1417 pItem->m_imageWidth,
1418 pItem->m_imageHeight
1419 );
1420 break;
1421 }
1422 case InteractableItem::LINK:
1423 case InteractableItem::EMBED_LINK:
1424 ConfirmOpenLink(pItem->m_destination);
1425 break;
1426 case InteractableItem::MENTION: {
1427 if (pItem->m_destination.size() < 2)
1428 break;
1429
1430 char mentType = pItem->m_destination[0];
1431 Snowflake sf = 0;
1432 if (pItem->m_destination[1] == '&') // roles do nothing
1433 break;
1434
1435 sf = pItem->m_affected;
1436 switch (mentType) {
1437 case '@': {
1438 if (pMsg->m_msg->IsWebHook())
1439 break;
1440
1441 RECT rect;
1442 GetWindowRect(m_hwnd, &rect);
1443 ProfilePopout::Show(sf, m_guildID, rect.left + pItem->m_rect.right + 10, rect.top + pItem->m_rect.top);
1444 break;
1445 }
1446 case '#': {
1447 // find channel
1448 Channel* pNewChan = GetDiscordInstance()->GetChannel(sf);
1449 if (!pNewChan)
1450 break;
1451
1452 Snowflake oldGuildID = m_guildID, oldChannelID = m_channelID;
1453
1454 if (oldGuildID != pNewChan->m_parentGuild)
1455 GetDiscordInstance()->OnSelectGuild(pNewChan->m_parentGuild);
1456

Callers 1

WndProcMethod · 0.80

Calls 7

CreateImageViewerFunction · 0.85
GetDiscordInstanceFunction · 0.85
IsWebHookMethod · 0.80
OnSelectGuildMethod · 0.80
OnSelectChannelMethod · 0.80
sizeMethod · 0.45
GetChannelMethod · 0.45

Tested by

no test coverage detected