From b20245c8c871fd177577c398316ea11da65c16e3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 10 Jun 2016 18:11:44 +0300 Subject: [PATCH] Fixed glitches in draft apply. Fixed overflow / crash in media preview. Fixed new unread messages with existing unread bar in the shown history. --- Telegram/SourceFiles/historywidget.cpp | 25 +++++++++++++++++++++---- Telegram/SourceFiles/historywidget.h | 2 ++ Telegram/SourceFiles/layerwidget.cpp | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index a4a91a9414..36f4e57e7f 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3856,8 +3856,12 @@ void HistoryWidget::applyDraft(bool parseLinks) { } void HistoryWidget::applyCloudDraft(History *history) { - if (_history == history) { + if (_history == history && !_editMsgId) { applyDraft(); + + updateControlsVisibility(); + resizeEvent(nullptr); + update(); } } @@ -4034,7 +4038,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re } applyDraft(false); - resizeEvent(0); + resizeEvent(nullptr); if (!_previewCancelled) { onPreviewParse(); } @@ -4671,8 +4675,21 @@ bool HistoryWidget::doWeReadServerHistory() const { if (scrollBottom > _list->itemTop(showFrom)) return true; } } - if (_history->showFrom && !_history->showFrom->detached() && _history->unreadBar) return true; - if (_migrated && _migrated->showFrom && !_migrated->showFrom->detached() && _migrated->unreadBar) return true; + if (historyHasNotFreezedUnreadBar(_history)) { + return true; + } + if (historyHasNotFreezedUnreadBar(_migrated)) { + return true; + } + return false; +} + +bool HistoryWidget::historyHasNotFreezedUnreadBar(History *history) const { + if (history && history->showFrom && !history->showFrom->detached() && history->unreadBar) { + if (auto unreadBar = history->unreadBar->Get()) { + return !unreadBar->_freezed; + } + } return false; } diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 4f00472106..7305899af9 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -857,6 +857,8 @@ private: void moveFieldControls(); void updateFieldSize(); + bool historyHasNotFreezedUnreadBar(History *history) const; + void clearInlineBot(); void inlineBotChanged(); diff --git a/Telegram/SourceFiles/layerwidget.cpp b/Telegram/SourceFiles/layerwidget.cpp index a649121556..54d0615264 100644 --- a/Telegram/SourceFiles/layerwidget.cpp +++ b/Telegram/SourceFiles/layerwidget.cpp @@ -202,7 +202,7 @@ void MediaPreviewWidget::paintEvent(QPaintEvent *e) { QRect r(e->rect()); const QPixmap &draw(currentImage()); - uint32 w = draw.width() / cIntRetinaFactor(), h = draw.height() / cIntRetinaFactor(); + int w = draw.width() / cIntRetinaFactor(), h = draw.height() / cIntRetinaFactor(); if (_a_shown.animating()) { float64 shown = a_shown.current(); p.setOpacity(shown);