2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Pass Main::Session to click handler creators.

This commit is contained in:
John Preston
2020-06-09 13:36:40 +04:00
parent fc174f742a
commit 03dec15e8e
21 changed files with 117 additions and 93 deletions

View File

@@ -389,10 +389,12 @@ void HistoryMessageReply::refreshReplyToDocument() {
}
ReplyMarkupClickHandler::ReplyMarkupClickHandler(
not_null<Data::Session*> owner,
int row,
int column,
FullMsgId context)
: _itemId(context)
: _owner(owner)
, _itemId(context)
, _row(row)
, _column(column) {
}
@@ -423,15 +425,11 @@ QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const {
// Note: it is possible that we will point to the different button
// than the one was used when constructing the handler, but not a big deal.
const HistoryMessageMarkupButton *ReplyMarkupClickHandler::getButton() const {
return HistoryMessageMarkupButton::Get(
&Auth().data(),
_itemId,
_row,
_column);
return HistoryMessageMarkupButton::Get(_owner, _itemId, _row, _column);
}
void ReplyMarkupClickHandler::onClickImpl() const {
if (const auto item = Auth().data().message(_itemId)) {
if (const auto item = _owner->message(_itemId)) {
App::activateBotCommand(item, _row, _column);
}
}
@@ -459,6 +457,7 @@ ReplyKeyboard::ReplyKeyboard(
})
, _st(std::move(s)) {
if (const auto markup = _item->Get<HistoryMessageReplyMarkup>()) {
const auto owner = &_item->history()->owner();
const auto context = _item->fullId();
const auto rowCount = int(markup->rows.size());
_rows.reserve(rowCount);
@@ -472,6 +471,7 @@ ReplyKeyboard::ReplyKeyboard(
const auto text = row[j].text;
button.type = row.at(j).type;
button.link = std::make_shared<ReplyMarkupClickHandler>(
owner,
i,
j,
context);