Show pin confirmation correctly in topics.

This commit is contained in:
John Preston 2023-04-21 15:09:06 +04:00
parent b782569faf
commit 05b8b9f22e
3 changed files with 9 additions and 6 deletions

View File

@ -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<Ui::GenericBox*> box,
not_null<PeerData*> peer,
MsgId msgId) {
not_null<HistoryItem*> item) {
struct State {
QPointer<Ui::Checkbox> pinForPeer;
QPointer<Ui::Checkbox> 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<State>();
const auto api = box->lifetime().make_state<MTP::Sender>(
&peer->session().mtp());

View File

@ -13,5 +13,4 @@ class GenericBox;
void PinMessageBox(
not_null<Ui::GenericBox*> box,
not_null<PeerData*> peer,
MsgId msgId);
not_null<HistoryItem*> item);

View File

@ -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;