mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 21:03:27 +01:00
don't sort after every friend add on statup
This commit is contained in:
parent
2fde13530b
commit
a2af0bc047
@ -113,7 +113,7 @@ static void friendlist_onStatusMessageChange(ToxWindow *self, int num, uint8_t *
|
||||
friends[num].statusmsg_len = len;
|
||||
}
|
||||
|
||||
static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num)
|
||||
static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num, bool sort)
|
||||
{
|
||||
if (max_friends_index < 0 || max_friends_index >= MAX_FRIENDS_NUM)
|
||||
return;
|
||||
@ -142,7 +142,9 @@ static void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num)
|
||||
if (i == max_friends_index)
|
||||
++max_friends_index;
|
||||
|
||||
sort_friendlist_index();
|
||||
if (sort)
|
||||
sort_friendlist_index();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
||||
wprintw(window, "Failed to add friend.\n");
|
||||
else {
|
||||
wprintw(window, "Friend request accepted.\n");
|
||||
on_friendadded(m, friendnum);
|
||||
on_friendadded(m, friendnum, true);
|
||||
}
|
||||
|
||||
memset(&pending_frnd_requests[req], 0, TOX_CLIENT_ID_SIZE);
|
||||
@ -142,7 +142,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX
|
||||
break;
|
||||
default:
|
||||
wprintw(window, "Friend request sent.\n");
|
||||
on_friendadded(m, f_num);
|
||||
on_friendadded(m, f_num, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ static void load_data(Tox *m, char *path)
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH];
|
||||
|
||||
while (tox_get_name(m, i, name) != -1)
|
||||
on_friendadded(m, i++);
|
||||
on_friendadded(m, i++, false);
|
||||
|
||||
free(buf);
|
||||
fclose(fd);
|
||||
|
@ -46,9 +46,7 @@ void print_time(WINDOW *window)
|
||||
{
|
||||
struct tm *timeinfo = get_time();
|
||||
|
||||
//wattron(window, COLOR_PAIR(CYAN));
|
||||
wprintw(window, "[%02d:%02d:%02d] ", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
|
||||
//wattroff(window, COLOR_PAIR(CYAN));
|
||||
}
|
||||
|
||||
/* Returns 1 if the string is empty, 0 otherwise */
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define MAX_FRIENDS_NUM 100
|
||||
#define MAX_STR_SIZE 256
|
||||
#define KEY_SIZE_BYTES 32
|
||||
#define TOXIC_MAX_NAME_LENGTH 32 /* Must be <= TOX_MAX_NAME_LENGTH */
|
||||
#define TOXIC_MAX_NAME_LENGTH 32 /* Must be < TOX_MAX_NAME_LENGTH */
|
||||
#define N_DEFAULT_WINS 2 /* number of permanent default windows */
|
||||
#define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */
|
||||
#define CHATBOX_HEIGHT 4
|
||||
@ -59,7 +59,7 @@ struct ToxWindow {
|
||||
void(*onDraw)(ToxWindow *, Tox *);
|
||||
void(*onInit)(ToxWindow *, Tox *);
|
||||
void(*onFriendRequest)(ToxWindow *, uint8_t *, uint8_t *, uint16_t);
|
||||
void(*onFriendAdded)(ToxWindow *, Tox *, int);
|
||||
void(*onFriendAdded)(ToxWindow *, Tox *, int, bool);
|
||||
void(*onConnectionChange)(ToxWindow *, Tox *, int, uint8_t);
|
||||
void(*onMessage)(ToxWindow *, Tox *, int, uint8_t *, uint16_t);
|
||||
void(*onNickChange)(ToxWindow *, int, uint8_t *, uint16_t);
|
||||
@ -138,7 +138,7 @@ void on_action(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void
|
||||
void on_nickchange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||
void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *userdata);
|
||||
void on_statusmessagechange(Tox *m, int friendnumber, uint8_t *string, uint16_t length, void *userdata);
|
||||
void on_friendadded(Tox *m, int friendnumber);
|
||||
void on_friendadded(Tox *m, int friendnumber, bool sort);
|
||||
void on_groupmessage(Tox *m, int groupnumber, int peernumber, uint8_t *message, uint16_t length, void *userdata);
|
||||
void on_groupinvite(Tox *m, int friendnumber, uint8_t *group_pub_key, void *userdata);
|
||||
void on_group_namelistchange(Tox *m, int groupnumber, int peernumber, uint8_t change, void *userdata);
|
||||
|
@ -93,13 +93,13 @@ void on_statuschange(Tox *m, int friendnumber, TOX_USERSTATUS status, void *user
|
||||
}
|
||||
}
|
||||
|
||||
void on_friendadded(Tox *m, int friendnumber)
|
||||
void on_friendadded(Tox *m, int friendnumber, bool sort)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
|
||||
if (windows[i].onFriendAdded != NULL)
|
||||
windows[i].onFriendAdded(&windows[i], m, friendnumber);
|
||||
windows[i].onFriendAdded(&windows[i], m, friendnumber, sort);
|
||||
}
|
||||
|
||||
if (store_data(m, DATA_FILE))
|
||||
@ -321,18 +321,20 @@ static void draw_bar(void)
|
||||
void draw_active_window(Tox *m)
|
||||
{
|
||||
ToxWindow *a = active_window;
|
||||
a->alert1 = false;
|
||||
a->alert2 = false;
|
||||
|
||||
wint_t ch = 0;
|
||||
|
||||
draw_bar();
|
||||
|
||||
touchwin(a->window);
|
||||
#ifndef WIN32
|
||||
wresize(a->window, LINES - 2, COLS);
|
||||
#endif
|
||||
|
||||
a->alert1 = false;
|
||||
a->alert2 = false;
|
||||
|
||||
draw_bar();
|
||||
a->onDraw(a, m);
|
||||
wrefresh(a->window);
|
||||
|
||||
/* Handle input */
|
||||
#ifdef HAVE_WIDECHAR
|
||||
|
Loading…
Reference in New Issue
Block a user