diff --git a/Telegram/SourceFiles/boxes/pin_messages_box.cpp b/Telegram/SourceFiles/boxes/pin_messages_box.cpp index 3471ef226..163e9dedc 100644 --- a/Telegram/SourceFiles/boxes/pin_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/pin_messages_box.cpp @@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat.h" #include "data/data_user.h" #include "lang/lang_keys.h" +#include "history/history.h" +#include "history/history_item.h" #include "main/main_session.h" #include "ui/boxes/confirm_box.h" #include "ui/widgets/checkbox.h" @@ -41,15 +43,17 @@ namespace { void PinMessageBox( not_null box, - not_null peer, - MsgId msgId) { + not_null item) { struct State { QPointer pinForPeer; QPointer notify; mtpRequestId requestId = 0; }; - const auto pinningOld = IsOldForPin(msgId, peer, MsgId(0)); + const auto peer = item->history()->peer; + const auto msgId = item->id; + const auto topicRootId = item->topic() ? item->topicRootId() : MsgId(); + const auto pinningOld = IsOldForPin(msgId, peer, topicRootId); const auto state = box->lifetime().make_state(); const auto api = box->lifetime().make_state( &peer->session().mtp()); diff --git a/Telegram/SourceFiles/boxes/pin_messages_box.h b/Telegram/SourceFiles/boxes/pin_messages_box.h index c3ff2e92e..e19d9a1f1 100644 --- a/Telegram/SourceFiles/boxes/pin_messages_box.h +++ b/Telegram/SourceFiles/boxes/pin_messages_box.h @@ -13,5 +13,4 @@ class GenericBox; void PinMessageBox( not_null box, - not_null peer, - MsgId msgId); + not_null item); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index ba06bf54d..1b73d6e65 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -2154,7 +2154,7 @@ void ToggleMessagePinned( } if (pin) { navigation->parentController()->show( - Box(PinMessageBox, item->history()->peer, item->id), + Box(PinMessageBox, item), Ui::LayerOption::CloseOther); } else { const auto peer = item->history()->peer;