From 675499df4d53d3f39c8c2056397ec4d4c4d0206f Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Sat, 2 Dec 2017 14:22:48 +0400
Subject: [PATCH] Fix render bug in single column layout.

---
 Telegram/SourceFiles/history/history_top_bar_widget.cpp | 7 ++++++-
 Telegram/SourceFiles/history/history_top_bar_widget.h   | 1 +
 Telegram/SourceFiles/history/history_widget.cpp         | 2 +-
 Telegram/SourceFiles/mainwidget.cpp                     | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Telegram/SourceFiles/history/history_top_bar_widget.cpp b/Telegram/SourceFiles/history/history_top_bar_widget.cpp
index 6046103aa..6eb8395ab 100644
--- a/Telegram/SourceFiles/history/history_top_bar_widget.cpp
+++ b/Telegram/SourceFiles/history/history_top_bar_widget.cpp
@@ -439,11 +439,16 @@ void HistoryTopBarWidget::updateControlsGeometry() {
 	updateMembersShowArea();
 }
 
+void HistoryTopBarWidget::finishAnimating() {
+	_selectedShown.finish();
+	updateControlsVisibility();
+}
+
 void HistoryTopBarWidget::setAnimationMode(bool enabled) {
 	if (_animationMode != enabled) {
 		_animationMode = enabled;
 		setAttribute(Qt::WA_OpaquePaintEvent, !_animationMode);
-		_selectedShown.finish();
+		finishAnimating();
 		updateControlsVisibility();
 	}
 }
diff --git a/Telegram/SourceFiles/history/history_top_bar_widget.h b/Telegram/SourceFiles/history/history_top_bar_widget.h
index d7abcc4c1..f2904f72a 100644
--- a/Telegram/SourceFiles/history/history_top_bar_widget.h
+++ b/Telegram/SourceFiles/history/history_top_bar_widget.h
@@ -48,6 +48,7 @@ public:
 	};
 
 	void updateControlsVisibility();
+	void finishAnimating();
 	void showSelected(SelectedState state);
 	rpl::producer<bool> membersShowAreaActive() const {
 		return _membersShowAreaActive.events();
diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp
index c8e5f9260..36650d71a 100644
--- a/Telegram/SourceFiles/history/history_widget.cpp
+++ b/Telegram/SourceFiles/history/history_widget.cpp
@@ -3118,7 +3118,7 @@ void HistoryWidget::showAnimated(
 
 	_cacheUnder = params.oldContentCache;
 	show();
-	_topBar->updateControlsVisibility();
+	_topBar->finishAnimating();
 	historyDownAnimationFinish();
 	unreadMentionsAnimationFinish();
 	_topShadow->setVisible(params.withTopBarShadow ? false : true);
diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp
index d540ae1ca..21f88e2a3 100644
--- a/Telegram/SourceFiles/mainwidget.cpp
+++ b/Telegram/SourceFiles/mainwidget.cpp
@@ -657,8 +657,8 @@ bool MainWidget::setForwardDraft(PeerId peerId, const SelectedItemSet &items) {
 	if (_history->peer() == peer) {
 		_history->cancelReply();
 	}
-	Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
 	_history->onClearSelected();
+	Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
 	return true;
 }