From 1bd4d6b02b763002e88c2703bf834003cbf8538e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Thu, 18 Sep 2014 19:54:05 +0200 Subject: [PATCH] Prevent redundant name change messages. --- src/tox-weechat-tox-callbacks.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/tox-weechat-tox-callbacks.c b/src/tox-weechat-tox-callbacks.c index c1b70b4..1c40b91 100644 --- a/src/tox-weechat-tox-callbacks.c +++ b/src/tox-weechat-tox-callbacks.c @@ -135,21 +135,24 @@ tox_weechat_name_change_callback(Tox *tox, char *old_name = tox_weechat_get_name_nt(identity->tox, friend_number); char *new_name = tox_weechat_null_terminate(name, length); - if (chat && strcmp(old_name, new_name) != 0) + if (strcmp(old_name, new_name) != 0) { - tox_weechat_chat_queue_refresh(chat); + if (chat) + { + tox_weechat_chat_queue_refresh(chat); - weechat_printf(chat->buffer, + weechat_printf(chat->buffer, + "%s%s is now known as %s", + weechat_prefix("network"), + old_name, new_name); + } + + weechat_printf(identity->buffer, "%s%s is now known as %s", weechat_prefix("network"), old_name, new_name); } - weechat_printf(identity->buffer, - "%s%s is now known as %s", - weechat_prefix("network"), - old_name, new_name); - free(old_name); free(new_name); }