[empathy: 1/2] empathy-chat: properly count unread messages when the connection goes away (#653090)



commit 005e206844be26a15012cc235927531bd3e38420
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Jun 21 13:45:14 2011 +0200

    empathy-chat: properly count unread messages when the connection goes away (#653090)

 libempathy-gtk/empathy-chat.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index bb33130..cd73c1f 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -121,6 +121,7 @@ struct _EmpathyChatPriv {
 	GtkWidget         *search_bar;
 
 	guint              unread_messages;
+	guint              unread_messages_when_offline;
 	/* TRUE if the pending messages can be displayed. This is to avoid to show
 	 * pending messages *before* messages from logs. (#603980) */
 	gboolean           can_show_pending;
@@ -2688,6 +2689,8 @@ chat_invalidated_cb (EmpathyTpChat *tp_chat,
 	gtk_widget_set_sensitive (chat->input_text_view, FALSE);
 
 	chat_update_contacts_visibility (chat, FALSE);
+
+	priv->unread_messages_when_offline = priv->unread_messages;
 }
 
 static gboolean
@@ -4026,6 +4029,14 @@ empathy_chat_messages_read (EmpathyChat *self)
 	if (priv->tp_chat != NULL) {
 		empathy_tp_chat_acknowledge_all_messages (priv->tp_chat);
 	}
+
+	if (priv->unread_messages_when_offline > 0) {
+		/* We can't ack those as the connection has gone away so just consider
+		* them as read. */
+		priv->unread_messages -= priv->unread_messages_when_offline;
+		g_object_notify (G_OBJECT (self), "nb-unread-messages");
+		priv->unread_messages_when_offline = 0;
+	}
 }
 
 /* Return TRUE if on of the contacts in this chat is composing */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]