mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Properly display chatwin history
So far if one had enabled `/history` and did `/msg somenick` the history was loaded from file and displayed like this: ``` 04-04-17 15:23 - 3/4/2017: 01-01-00 10:30 - me: .... 01-01-00 10:31 - somebody: .... 01-01-00 10:32 - somebody: .... ``` So the first line contained the actual date. But the date used in each line was always 01-01-2000. This date was for some reason hardcoded. This commit now actually uses that date to build the proper GDateTime instead of just printing it. Fix https://github.com/profanity-im/profanity/issues/922
This commit is contained in:
parent
ef19b45e64
commit
40d9dcae87
@ -599,7 +599,6 @@ _groupchat_log_chat(const gchar *const login, const gchar *const room, const gch
|
|||||||
g_date_time_unref(dt);
|
g_date_time_unref(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
chat_log_get_previous(const gchar *const login, const gchar *const recipient)
|
chat_log_get_previous(const gchar *const login, const gchar *const recipient)
|
||||||
{
|
{
|
||||||
|
@ -467,19 +467,25 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact)
|
|||||||
GSList *history = chat_log_get_previous(jid->barejid, contact);
|
GSList *history = chat_log_get_previous(jid->barejid, contact);
|
||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
GSList *curr = history;
|
GSList *curr = history;
|
||||||
|
int idd;
|
||||||
|
int imo;
|
||||||
|
int iyy;
|
||||||
|
|
||||||
while (curr) {
|
while (curr) {
|
||||||
char *line = curr->data;
|
char *line = curr->data;
|
||||||
// entry
|
// entry, containing the actual entries with date followed by text
|
||||||
if (line[2] == ':') {
|
if (line[2] == ':') {
|
||||||
char hh[3]; memcpy(hh, &line[0], 2); hh[2] = '\0'; int ihh = atoi(hh);
|
char hh[3]; memcpy(hh, &line[0], 2); hh[2] = '\0'; int ihh = atoi(hh);
|
||||||
char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm);
|
char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm);
|
||||||
char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss);
|
char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss);
|
||||||
GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss);
|
GDateTime *timestamp = g_date_time_new_local(iyy, imo, idd, ihh, imm, iss);
|
||||||
win_print_history((ProfWin*)chatwin, timestamp, "%s", curr->data+11);
|
win_print_history((ProfWin*)chatwin, timestamp, "%s", curr->data+11);
|
||||||
g_date_time_unref(timestamp);
|
g_date_time_unref(timestamp);
|
||||||
// header
|
// header, containing the date from filename "21/10/2019:"
|
||||||
} else {
|
} else {
|
||||||
win_println((ProfWin*)chatwin, THEME_DEFAULT, '-', "%s", curr->data);
|
char dd[3]; memcpy(dd, &line[0], 2); dd[2] = '\0'; idd = atoi(dd);
|
||||||
|
char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; imo = atoi(mm);
|
||||||
|
char yy[5]; memcpy(yy, &line[6], 4); yy[4] = '\0'; iyy = atoi(yy);
|
||||||
}
|
}
|
||||||
curr = g_slist_next(curr);
|
curr = g_slist_next(curr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user