1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 11:13:24 +01:00

fix bug where contacts would appear online twice in a row

This commit is contained in:
Jfreegman 2015-03-31 18:39:42 -04:00
parent 4780cfeafc
commit eaea68c33e
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 6 additions and 3 deletions

View File

@ -332,7 +332,7 @@ static void friendlist_onConnectionChange(ToxWindow *self, Tox *m, uint32_t num,
if (connection_status == TOX_CONNECTION_NONE)
--Friends.num_online;
else
else if (Friends.list[num].connection_status == TOX_CONNECTION_NONE)
++Friends.num_online;
Friends.list[num].connection_status = connection_status;

View File

@ -31,6 +31,7 @@
#include "toxic.h"
#include "windows.h"
#include "prompt.h"
#include "friendlist.h"
#include "execute.h"
#include "misc_tools.h"
#include "toxic_strings.h"
@ -46,6 +47,7 @@ extern ToxWindow *prompt;
extern struct user_settings *user_settings;
extern struct Winthread Winthread;
extern FriendsList Friends;
FriendRequests FrndRequests;
#ifdef AUDIO
@ -346,7 +348,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnu
get_time_str(timefrmt, sizeof(timefrmt));
const char *msg;
if (connection_status != TOX_CONNECTION_NONE) {
if (connection_status != TOX_CONNECTION_NONE && Friends.list[friendnum].connection_status == TOX_CONNECTION_NONE) {
msg = "has come online";
line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, GREEN, msg);
write_to_log(msg, nick, ctx->log, true);
@ -357,7 +359,8 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnu
else
box_notify(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box,
"Toxic", "%s has come online", nick );
} else {
}
else if (connection_status == TOX_CONNECTION_NONE) {
msg = "has gone offline";
line_info_add(self, timefrmt, nick, NULL, DISCONNECTION, 0, RED, msg);
write_to_log(msg, nick, ctx->log, true);