diff options
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 222258082..bed7aa78e 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -96,7 +96,7 @@ typedef struct { GtkWidget *info_bar_vbox; GtkWidget *search_bar; - guint unread_messages; + GList *pending_messages; /* 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; @@ -1116,7 +1116,9 @@ chat_message_received (EmpathyChat *chat, EmpathyMessage *message) TP_CHANNEL_CHAT_STATE_ACTIVE, chat); - priv->unread_messages++; + priv->pending_messages = g_list_prepend (priv->pending_messages, + g_object_ref (message)); + g_signal_emit (chat, signals[NEW_MESSAGE], 0, message); } @@ -1126,7 +1128,6 @@ chat_message_received_cb (EmpathyTpChat *tp_chat, EmpathyChat *chat) { chat_message_received (chat, message); - empathy_tp_chat_acknowledge_message (tp_chat, message); } static void @@ -2065,7 +2066,6 @@ show_pending_messages (EmpathyChat *chat) { EmpathyMessage *message = EMPATHY_MESSAGE (l->data); chat_message_received (chat, message); } - empathy_tp_chat_acknowledge_messages (priv->tp_chat, messages); } static void @@ -2936,7 +2936,7 @@ empathy_chat_get_nb_unread_messages (EmpathyChat *self) g_return_val_if_fail (EMPATHY_IS_CHAT (self), FALSE); - return priv->unread_messages; + return g_list_length (priv->pending_messages); } /* called when the messages have been read by user */ @@ -2947,5 +2947,12 @@ empathy_chat_messages_read (EmpathyChat *self) g_return_if_fail (EMPATHY_IS_CHAT (self)); - priv->unread_messages = 0; + empathy_tp_chat_acknowledge_messages (priv->tp_chat, + priv->pending_messages); + + while (priv->pending_messages != NULL) { + g_object_unref (priv->pending_messages->data); + priv->pending_messages = g_list_delete_link ( + priv->pending_messages, priv->pending_messages); + } } |