about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-06-05 09:56:00 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-06-05 09:56:00 +0200
commitd53c477e4e2589e15267fe2b3de4bc59fe32aa3e (patch)
tree606c62faad1b28bdb29ccdb6ffa115dcd15d891f /src
parent13675fbf06a0d0fbae2b974596a0fb513ba22340 (diff)
downloadprofani-tty-d53c477e4e2589e15267fe2b3de4bc59fe32aa3e.tar.gz
Reduce timestamp call when saving last muc message
Let's test for mucwin earlier.
Diffstat (limited to 'src')
-rw-r--r--src/event/server_events.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index b496e3e2..85c0e6ca 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -273,20 +273,21 @@ sv_ev_room_history(const char *const room_jid, const char *const nick,
     GDateTime *timestamp, const char *const message)
 {
     ProfMucWin *mucwin = wins_get_muc(room_jid);
-
-    // if this is the first successful connection
-    if (_success_connections_counter == 1) {
-        // save timestamp of last received muc message
-        // so we dont display, if there was no activity in channel, once we reconnect
-        if (_last_muc_message) {
-            g_date_time_unref(_last_muc_message);
+    if (mucwin) {
+        // if this is the first successful connection
+        if (_success_connections_counter == 1) {
+            // save timestamp of last received muc message
+            // so we dont display, if there was no activity in channel, once we reconnect
+            if (_last_muc_message) {
+                g_date_time_unref(_last_muc_message);
+            }
+            _last_muc_message  = g_date_time_new_now_local();
         }
-        _last_muc_message  = g_date_time_new_now_local();
-    }
 
-    gboolean younger = g_date_time_compare(_last_muc_message, timestamp) < 0 ? TRUE : FALSE;
-    if (mucwin && (_success_connections_counter == 1 || younger )) {
-        mucwin_history(mucwin, nick, timestamp, message);
+        gboolean younger = g_date_time_compare(_last_muc_message, timestamp) < 0 ? TRUE : FALSE;
+        if (_success_connections_counter == 1 || younger ) {
+            mucwin_history(mucwin, nick, timestamp, message);
+        }
     }
 }