From 005e206844be26a15012cc235927531bd3e38420 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 21 Jun 2011 13:45:14 +0200 Subject: empathy-chat: properly count unread messages when the connection goes away (#653090) --- libempathy-gtk/empathy-chat.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index bb33130e3..cd73c1f0d 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 */ -- cgit v1.2.3