1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-03 15:47:46 +02:00

re-implement friendlist last seen

This commit is contained in:
Jfreegman 2015-04-02 22:19:09 -04:00
parent e998c8a866
commit 523f205646
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -409,7 +409,7 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, uint32_t num, bool sort)
if (err != TOX_ERR_FRIEND_GET_PUBLIC_KEY_OK) if (err != TOX_ERR_FRIEND_GET_PUBLIC_KEY_OK)
fprintf(stderr, "tox_friend_get_public_key failed (error %d)\n", err); fprintf(stderr, "tox_friend_get_public_key failed (error %d)\n", err);
// update_friend_last_online(i, 0); update_friend_last_online(i, tox_friend_get_last_online(m, num, NULL));
char tempname[TOX_MAX_NAME_LENGTH] = {0}; char tempname[TOX_MAX_NAME_LENGTH] = {0};
get_nick_truncate(m, tempname, num); get_nick_truncate(m, tempname, num);
@ -873,8 +873,8 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
return; return;
} }
// uint64_t cur_time = get_unix_time(); uint64_t cur_time = get_unix_time();
// struct tm cur_loc_tm = *localtime((const time_t *) &cur_time); struct tm cur_loc_tm = *localtime((const time_t *) &cur_time);
wattron(self->window, A_BOLD); wattron(self->window, A_BOLD);
wprintw(self->window, " Online: "); wprintw(self->window, " Online: ");
@ -979,34 +979,31 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
if (f_selected) if (f_selected)
wattroff(self->window, COLOR_PAIR(BLUE)); wattroff(self->window, COLOR_PAIR(BLUE));
wprintw(self->window, "\n"); uint64_t last_seen = Friends.list[f].last_online.last_on;
/* Last online is currently broken in core */
// uint64_t last_seen = Friends.list[f].last_online.last_on; if (last_seen != 0) {
// int day_dist = (
// if (last_seen != 0) { cur_loc_tm.tm_yday - Friends.list[f].last_online.tm.tm_yday
// int day_dist = ( + ((cur_loc_tm.tm_year - Friends.list[f].last_online.tm.tm_year) * 365)
// cur_loc_tm.tm_yday - Friends.list[f].last_online.tm.tm_yday );
// + ((cur_loc_tm.tm_year - Friends.list[f].last_online.tm.tm_year) * 365) const char *hourmin = Friends.list[f].last_online.hour_min_str;
// );
// const char *hourmin = Friends.list[f].last_online.hour_min_str;
// switch (day_dist) { switch (day_dist) {
// case 0: case 0:
// wprintw(self->window, " Last seen: Today %s\n", hourmin); wprintw(self->window, " Last seen: Today %s\n", hourmin);
// break; break;
// case 1: case 1:
// wprintw(self->window, " Last seen: Yesterday %s\n", hourmin); wprintw(self->window, " Last seen: Yesterday %s\n", hourmin);
// break; break;
// default: default:
// wprintw(self->window, " Last seen: %d days ago\n", day_dist); wprintw(self->window, " Last seen: %d days ago\n", day_dist);
// break; break;
// } }
// } else { } else {
// wprintw(self->window, " Last seen: Never\n"); wprintw(self->window, " Last seen: Never\n");
// } }
} }
} }
} }