]> git.0d.be Git - empathy.git/commitdiff
Get the original message from the logger so we can supersede it
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 20 May 2011 05:25:58 +0000 (15:25 +1000)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Mon, 13 Jun 2011 16:04:03 +0000 (17:04 +0100)
Strictly, we don't need to do this, we could just use the supersedes-token
as the message-token and we'd still be able to edit the messages in the future,
but this way we get the nice pretty annotation saying that we edited it and
when.

libempathy-gtk/empathy-chat.c

index 47f1e681521a6fa661c00a752c14851568f43b88..85a0b7793372cafedde5dfc575c38073a9cb3429 100644 (file)
@@ -38,6 +38,7 @@
 #include <telepathy-glib/account-manager.h>
 #include <telepathy-glib/util.h>
 #include <telepathy-logger/log-manager.h>
+#include <telepathy-logger/text-event.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-gsettings.h>
 #include <libempathy/empathy-keyring.h>
@@ -2331,12 +2332,32 @@ got_filtered_messages_cb (GObject *manager,
 
        for (l = messages; l; l = g_list_next (l)) {
                EmpathyMessage *message;
+               GList *supersedes;
                g_assert (TPL_IS_EVENT (l->data));
 
+               /* we need the last message this one supersedes, which is the
+                * the original */
+               supersedes = tpl_text_event_dup_supersedes (l->data);
+
+               if (supersedes != NULL) {
+                       message = empathy_message_from_tpl_log_event (
+                               g_list_last (supersedes)->data);
+                       empathy_chat_view_append_message (chat->view, message);
+
+                       g_object_unref (message);
+               }
+
+               g_list_free_full (supersedes, g_object_unref);
+
+               /* append the latest message */
                message = empathy_message_from_tpl_log_event (l->data);
                g_object_unref (l->data);
 
-               empathy_chat_view_append_message (chat->view, message);
+               if (empathy_message_is_edit (message))
+                       empathy_chat_view_edit_message (chat->view, message);
+               else
+                       empathy_chat_view_append_message (chat->view, message);
+
                g_object_unref (message);
        }
        g_list_free (messages);