From 070c3ae6cc1a0282b3d2e3fe277994eaa734f972 Mon Sep 17 00:00:00 2001
From: James Booth <boothj5@gmail.com>
Date: Sat, 27 Apr 2013 22:02:20 +0100
Subject: [PATCH] Show contacts status when receiveing messages via delayed
 delivery

---
 src/ui/core.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/ui/core.c b/src/ui/core.c
index b936b59b..19be6cbf 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -264,6 +264,7 @@ void
 ui_incoming_msg(const char * const from, const char * const message,
     GTimeVal *tv_stamp, gboolean priv)
 {
+    gboolean win_created = FALSE;
     char *display_from;
     win_type_t win_type;
     if (priv) {
@@ -275,8 +276,10 @@ ui_incoming_msg(const char * const from, const char * const message,
     }
 
     int win_index = _find_prof_win_index(from);
-    if (win_index == NUM_WINS)
+    if (win_index == NUM_WINS) {
         win_index = _new_prof_win(from, win_type);
+        win_created = TRUE;
+    }
 
     // no spare windows left
     if (win_index == 0) {
@@ -359,6 +362,11 @@ ui_incoming_msg(const char * const from, const char * const message,
             if (tv_stamp == NULL) {
                 win_print_time(window, '-');
             } else {
+                // if show users status first, when receiving message via delayed delivery
+                if (win_created) {
+                    PContact pcontact = contact_list_get_contact(from);
+                    win_show_contact(window, pcontact);
+                }
                 GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
                 gchar *date_fmt = g_date_time_format(time, "%H:%M:%S");
                 wattron(window->win, COLOUR_TIME);