about summary refs log tree commit diff stats
path: root/src/event/server_events.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-07-03 09:19:24 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-07-03 09:19:24 +0200
commitad9263520e8c3c151d48ba579bece5f705c2131e (patch)
tree02ce1fcf26a5a6f0270b069c51d2279e7efe8fc1 /src/event/server_events.c
parent9f813445b719ed0201a432c3c6a7dfeceaa5da83 (diff)
downloadprofani-tty-ad9263520e8c3c151d48ba579bece5f705c2131e.tar.gz
Show MUC history on intentional reconnect
Small bug caused by 13675fb and ce5a4ed.
Fix https://github.com/profanity-im/profanity/issues/1142
Diffstat (limited to 'src/event/server_events.c')
-rw-r--r--src/event/server_events.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 97dabb5f..86a9ae8d 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -67,8 +67,6 @@
 
 #include "ui/ui.h"
 
-gint _success_connections_counter = 0;
-
 void
 sv_ev_login_account_success(char *account_name, gboolean secured)
 {
@@ -104,13 +102,13 @@ sv_ev_login_account_success(char *account_name, gboolean secured)
     log_info("%s logged in successfully", account->jid);
 
     // if we have been connected before
-    if (_success_connections_counter > 0)
+    if (ev_was_connected_already())
     {
         cons_show("Connection re-established.");
         wins_reestablished_connection();
     }
 
-    _success_connections_counter++;
+    ev_inc_connection_counter();
 
     if (account->startscript) {
         scripts_exec(account->startscript);
@@ -261,7 +259,7 @@ sv_ev_room_subject(const char *const room, const char *const nick, const char *c
 {
     muc_set_subject(room, subject);
     ProfMucWin *mucwin = wins_get_muc(room);
-    if (mucwin && muc_roster_complete(room) && _success_connections_counter == 1) {
+    if (mucwin && muc_roster_complete(room) && ev_is_first_connect()) {
         mucwin_subject(mucwin, nick, subject);
     }
 }
@@ -272,7 +270,7 @@ sv_ev_room_history(ProfMessage *message)
     ProfMucWin *mucwin = wins_get_muc(message->jid->barejid);
     if (mucwin) {
         // if this is the first successful connection
-        if (_success_connections_counter == 1) {
+        if (ev_is_first_connect()) {
             // save timestamp of last received muc message
             // so we dont display, if there was no activity in channel, once we reconnect
             if (mucwin->last_msg_timestamp) {
@@ -282,7 +280,7 @@ sv_ev_room_history(ProfMessage *message)
         }
 
         gboolean younger = g_date_time_compare(mucwin->last_msg_timestamp, message->timestamp) < 0 ? TRUE : FALSE;
-        if (_success_connections_counter == 1 || younger ) {
+        if (ev_is_first_connect() || younger ) {
             mucwin_history(mucwin, message->jid->resourcepart, message->timestamp, message->plain);
         }
     }