From bbe47f55d18b6f9e530ac2c8d0d3aebb0ec72f8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Fri, 30 Sep 2011 23:03:51 +0200
Subject: Only do the "Mark unread messages as read" dance if there are unread
 messages.

This should avoid some juddery scrolling.

diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index 802a7cb..df59c2f 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -90,12 +90,14 @@ void ChatControllerBase::setAvailableServerFeatures(boost::shared_ptr<DiscoInfo>
 }
 
 void ChatControllerBase::handleAllMessagesRead() {
-	foreach (boost::shared_ptr<MessageEvent> messageEvent, unreadMessages_) {
-		messageEvent->read();
+	if (!unreadMessages_.empty()) {
+		foreach (boost::shared_ptr<MessageEvent> messageEvent, unreadMessages_) {
+			messageEvent->read();
+		}
+		unreadMessages_.clear();
+		chatWindow_->setUnreadMessageCount(0);
+		onUnreadCountChanged();
 	}
-	unreadMessages_.clear();
-	chatWindow_->setUnreadMessageCount(0);
-	onUnreadCountChanged();
 }
 
 int ChatControllerBase::getUnreadCount() {
-- 
cgit v0.10.2-6-g49f6