Only update userlistgui when necessary

This commit is contained in:
TingPing 2013-10-26 13:37:20 -04:00
parent 7cf9ea83cb
commit a1c9294b89
1 changed files with 9 additions and 7 deletions

View File

@ -139,30 +139,32 @@ userlist_add_hostname (struct session *sess, char *nick, char *hostname,
char *realname, char *servername, char *account, unsigned int away) char *realname, char *servername, char *account, unsigned int away)
{ {
struct User *user; struct User *user;
gboolean do_rehash = FALSE;
user = userlist_find (sess, nick); user = userlist_find (sess, nick);
if (user) if (user)
{ {
if (!user->hostname && hostname) if (!user->hostname && hostname)
{
if (prefs.hex_gui_ulist_show_hosts)
do_rehash = TRUE;
user->hostname = strdup (hostname); user->hostname = strdup (hostname);
}
if (!user->realname && realname) if (!user->realname && realname)
user->realname = strdup (realname); user->realname = strdup (realname);
if (!user->servername && servername) if (!user->servername && servername)
user->servername = strdup (servername); user->servername = strdup (servername);
if (!user->account && account && strcmp (account, "0") != 0) if (!user->account && account && strcmp (account, "0") != 0)
user->account = strdup (account); user->account = strdup (account);
if (away != 0xff) if (away != 0xff)
{ {
if (prefs.hex_gui_ulist_show_hosts || user->away != away) if (user->away != away)
{ do_rehash = TRUE;
user->away = away;
fe_userlist_rehash (sess, user);
}
user->away = away; user->away = away;
} }
fe_userlist_update (sess, user); fe_userlist_update (sess, user);
if (do_rehash)
fe_userlist_rehash (sess, user); fe_userlist_rehash (sess, user);
return 1; return 1;