diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-06-11 07:00:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-11 07:00:34 +0200 |
commit | 5dd6ba73f43e8540872cb01ea3549c7d6e972101 (patch) | |
tree | bbcb42a421fa6f25613addf4be45d3a13c592eaa /src/event | |
parent | da54eaf42b88be62bfebbb84dd11cb9bdd4cd9bd (diff) | |
parent | 47e55cc1127a80397ed139bd70443cc7c277d006 (diff) | |
download | profani-tty-5dd6ba73f43e8540872cb01ea3549c7d6e972101.tar.gz |
Merge pull request #1110 from profanity-im/feature/704-ui-behaviour-reconnect
Feature/704 ui behaviour reconnect
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/server_events.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c index 7b57ef4b..269de51b 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -66,6 +66,8 @@ #include "ui/ui.h" +gint _success_connections_counter = 0; + void sv_ev_login_account_success(char *account_name, gboolean secured) { @@ -100,6 +102,15 @@ 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) + { + cons_show("Connection re-established."); + wins_reestablished_connection(); + } + + _success_connections_counter++; + if (account->startscript) { scripts_exec(account->startscript); } @@ -249,7 +260,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)) { + if (mucwin && muc_roster_complete(room) && _success_connections_counter == 1) { mucwin_subject(mucwin, nick, subject); } } @@ -260,7 +271,20 @@ sv_ev_room_history(const char *const room_jid, const char *const nick, { ProfMucWin *mucwin = wins_get_muc(room_jid); if (mucwin) { - mucwin_history(mucwin, nick, timestamp, message); + // 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 (mucwin->last_msg_timestamp) { + g_date_time_unref(mucwin->last_msg_timestamp); + } + mucwin->last_msg_timestamp = g_date_time_new_now_local(); + } + + gboolean younger = g_date_time_compare(mucwin->last_msg_timestamp, timestamp) < 0 ? TRUE : FALSE; + if (_success_connections_counter == 1 || younger ) { + mucwin_history(mucwin, nick, timestamp, message); + } } } @@ -336,6 +360,12 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha } } + // save timestamp of last received muc message + if (mucwin->last_msg_timestamp) { + g_date_time_unref(mucwin->last_msg_timestamp); + } + mucwin->last_msg_timestamp = g_date_time_new_now_local(); + if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, nick, new_message, mention, triggers != NULL)) { Jid *jidp = jid_create(mucwin->roomjid); notify_room_message(nick, jidp->localpart, num, new_message); |