From 85e234938d6bc75af11c185d321af56249fd451d Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 24 Jun 2017 13:32:30 +0300 Subject: [PATCH] Fix inline keyboard. Disable it in the event log. Also disable game preview click handler in the event log. --- Telegram/SourceFiles/history/history_item.cpp | 4 ++++ Telegram/SourceFiles/history/history_media.h | 2 ++ .../SourceFiles/history/history_media_types.cpp | 16 +++++++++++++--- .../SourceFiles/history/history_media_types.h | 1 + Telegram/SourceFiles/history/history_message.cpp | 4 ++-- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 7ed230ec56..0a49aa5a00 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -797,6 +797,10 @@ void HistoryItem::setId(MsgId newId) { markup->inlineKeyboard->updateMessageId(); } } + + if (_media) { + _media->updateMessageId(); + } } bool HistoryItem::canPin() const { diff --git a/Telegram/SourceFiles/history/history_media.h b/Telegram/SourceFiles/history/history_media.h index a658b8ca62..2a571234fe 100644 --- a/Telegram/SourceFiles/history/history_media.h +++ b/Telegram/SourceFiles/history/history_media.h @@ -60,6 +60,8 @@ public: return false; } virtual void initDimensions() = 0; + virtual void updateMessageId() { + } virtual int resizeGetHeight(int width) { _width = qMin(width, _maxw); return _height; diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index a30eb47f7a..33433ee3a3 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -3696,7 +3696,7 @@ HistoryGame::HistoryGame(gsl::not_null parent, const HistoryGame & void HistoryGame::initDimensions() { auto lineHeight = unitedLineHeight(); - if (!_openl) { + if (!_openl && _parent->id > 0) { _openl = MakeShared(_parent, 0, 0); } @@ -3774,6 +3774,12 @@ void HistoryGame::initDimensions() { } } +void HistoryGame::updateMessageId() { + if (_openl) { + _openl = MakeShared(_parent, 0, 0); + } +} + int HistoryGame::resizeGetHeight(int width) { _width = width = qMin(width, _maxw); width -= st::msgPadding.left() + st::webPageLeft + st::msgPadding.right(); @@ -3934,7 +3940,9 @@ HistoryTextState HistoryGame::getState(QPoint point, HistoryStateRequest request tshift += _descriptionLines * lineHeight; } if (inThumb) { - result.link = _openl; + if (!_parent->isLogEntry()) { + result.link = _openl; + } } else if (_attach) { auto attachAtTop = !_titleLines && !_descriptionLines; if (!attachAtTop) tshift += st::mediaInBubbleSkip; @@ -3945,7 +3953,9 @@ HistoryTextState HistoryGame::getState(QPoint point, HistoryStateRequest request if (QRect(attachLeft, tshift, _attach->currentWidth(), _height - tshift - bshift).contains(point)) { if (_attach->isReadyForOpen()) { - result.link = _openl; + if (!_parent->isLogEntry()) { + result.link = _openl; + } } else { result = _attach->getState(point - QPoint(attachLeft, attachTop), request); } diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index 23231a0d93..b4d20182a9 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -882,6 +882,7 @@ public: void initDimensions() override; int resizeGetHeight(int width) override; + void updateMessageId() override; void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override; HistoryTextState getState(QPoint point, HistoryStateRequest request) const override; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 7d42d835c3..c25858cb84 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -1792,10 +1792,10 @@ HistoryTextState HistoryMessage::getState(QPoint point, HistoryStateRequest requ result.symbol += _text.length(); } - if (keyboard) { + if (keyboard && !isLogEntry()) { auto keyboardTop = g.top() + g.height() + st::msgBotKbButton.margin; if (QRect(g.left(), keyboardTop, g.width(), keyboardHeight).contains(point)) { - result.link = keyboard->getState(point - g.topLeft()); + result.link = keyboard->getState(point - QPoint(g.left(), keyboardTop)); return result; } }