From 749b2e0e955b3df1f341d1050614677591d3e39b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 4 Jun 2024 17:41:24 +0300 Subject: [PATCH] Added ability to see vcard if available to all types if contacts media. --- Telegram/SourceFiles/history/history_item.cpp | 4 ++-- .../view/media/history_view_contact.cpp | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 5a434c3a64..73b92e21d5 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -249,8 +249,8 @@ std::unique_ptr HistoryItem::CreateMedia( } else if (type.startsWith("BDAY")) { items[Type::Birthday] = value; } else if (type.startsWith("N")) { - items[Type::Birthday] = value; - items[Type::Birthday].replace(';', ' '); + items[Type::Name] = value; + items[Type::Name].replace(';', ' '); } } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp index d0fbfe7302..dc8995903d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_contact.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp @@ -189,7 +189,15 @@ ClickHandlerPtr AddContactClickHandler(not_null item) { }); } } - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); + { + const auto inner = box->verticalLayout(); + if (inner->count() > 2) { + delete inner->widgetAt(inner->count() - 1); + delete inner->widgetAt(inner->count() - 1); + } + } + + box->addButton(tr::lng_close(), [=] { box->closeBox(); }); }; } @@ -259,6 +267,7 @@ QSize Contact::countOptimalSize() { full); } + const auto vcardBoxFactory = _vcardBoxFactory; _buttons.clear(); if (_contact) { const auto message = tr::lng_contact_send_message(tr::now).toUpper(); @@ -276,20 +285,20 @@ QSize Contact::countOptimalSize() { }); } _mainButton.link = _buttons.front().link; - } else if (const auto vcardBoxFactory = _vcardBoxFactory) { + } else if (vcardBoxFactory) { const auto view = tr::lng_contact_details_button(tr::now).toUpper(); _buttons.push_back({ view, st::semiboldFont->width(view), AddContactClickHandler(_parent->data()), }); + } + if (vcardBoxFactory) { _mainButton.link = std::make_shared([=]( const ClickContext &context) { const auto my = context.other.value(); if (const auto controller = my.sessionWindow.get()) { - controller->uiShow()->show(Box([=](not_null box) { - vcardBoxFactory(box); - })); + controller->uiShow()->show(Box(vcardBoxFactory)); } }); }