Removed App::wnd() from HistoryView::Contact.
This commit is contained in:
parent
024bb5e54f
commit
ca83b8a8c6
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "history/view/media/history_view_contact.h"
|
#include "history/view/media/history_view_contact.h"
|
||||||
|
|
||||||
|
#include "core/click_handler_types.h" // ClickHandlerContext
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "layout/layout_selection.h"
|
#include "layout/layout_selection.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -25,32 +26,44 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_cloud_file.h"
|
#include "data/data_cloud_file.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "app.h"
|
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
ClickHandlerPtr sendMessageClickHandler(PeerData *peer) {
|
ClickHandlerPtr SendMessageClickHandler(PeerData *peer) {
|
||||||
return std::make_shared<LambdaClickHandler>([peer] {
|
return std::make_shared<LambdaClickHandler>([peer](ClickContext context) {
|
||||||
App::wnd()->sessionController()->showPeerHistory(
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
peer->id,
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
Window::SectionShow::Way::Forward);
|
if (controller->session().uniqueId()
|
||||||
|
!= peer->session().uniqueId()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
controller->showPeerHistory(
|
||||||
|
peer->id,
|
||||||
|
Window::SectionShow::Way::Forward);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickHandlerPtr addContactClickHandler(not_null<HistoryItem*> item) {
|
ClickHandlerPtr AddContactClickHandler(not_null<HistoryItem*> item) {
|
||||||
const auto session = &item->history()->session();
|
const auto session = &item->history()->session();
|
||||||
const auto fullId = item->fullId();
|
const auto fullId = item->fullId();
|
||||||
return std::make_shared<LambdaClickHandler>([=] {
|
return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
||||||
if (const auto item = session->data().message(fullId)) {
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
if (const auto media = item->media()) {
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
if (const auto contact = media->sharedContact()) {
|
if (controller->session().uniqueId() != session->uniqueId()) {
|
||||||
Ui::show(Box<AddContactBox>(
|
return;
|
||||||
session,
|
}
|
||||||
contact->firstName,
|
if (const auto item = session->data().message(fullId)) {
|
||||||
contact->lastName,
|
if (const auto media = item->media()) {
|
||||||
contact->phoneNumber));
|
if (const auto contact = media->sharedContact()) {
|
||||||
|
controller->show(Box<AddContactBox>(
|
||||||
|
session,
|
||||||
|
contact->firstName,
|
||||||
|
contact->lastName,
|
||||||
|
contact->phoneNumber));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,10 +126,10 @@ QSize Contact::countOptimalSize() {
|
||||||
full);
|
full);
|
||||||
}
|
}
|
||||||
if (_contact && _contact->isContact()) {
|
if (_contact && _contact->isContact()) {
|
||||||
_linkl = sendMessageClickHandler(_contact);
|
_linkl = SendMessageClickHandler(_contact);
|
||||||
_link = tr::lng_profile_send_message(tr::now).toUpper();
|
_link = tr::lng_profile_send_message(tr::now).toUpper();
|
||||||
} else if (_userId) {
|
} else if (_userId) {
|
||||||
_linkl = addContactClickHandler(_parent->data());
|
_linkl = AddContactClickHandler(_parent->data());
|
||||||
_link = tr::lng_profile_add_contact(tr::now).toUpper();
|
_link = tr::lng_profile_add_contact(tr::now).toUpper();
|
||||||
}
|
}
|
||||||
_linkw = _link.isEmpty() ? 0 : st::semiboldFont->width(_link);
|
_linkw = _link.isEmpty() ? 0 : st::semiboldFont->width(_link);
|
||||||
|
|
Loading…
Reference in New Issue