Add loading history message on initial MAM request
This prevents scrolling to top and initiating another MAM request while still fetching the initial one. Also free timestamp object in database.c
This commit is contained in:
@@ -102,6 +102,7 @@ chatwin_new(const char* const barejid)
|
||||
|
||||
if (prefs_get_boolean(PREF_MAM)) {
|
||||
iq_mam_request(chatwin);
|
||||
win_print_loading_history(window);
|
||||
}
|
||||
|
||||
return chatwin;
|
||||
|
||||
@@ -610,8 +610,7 @@ win_page_up(ProfWin* window)
|
||||
if (first_entry && !(first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, loading_text) == 0)) {
|
||||
if (!chatwin_old_history(chatwin, NULL)) {
|
||||
cons_show("Fetched mam");
|
||||
buffer_prepend(window->layout->buffer, "-", 0, first_entry->time, NO_DATE, THEME_ROOMINFO, NULL, NULL, loading_text, NULL, NULL);
|
||||
win_redraw(window);
|
||||
win_print_loading_history(window);
|
||||
iq_mam_request_older(chatwin);
|
||||
} else {
|
||||
cons_show("Showed history");
|
||||
@@ -1855,6 +1854,15 @@ win_redraw(ProfWin* window)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_print_loading_history(ProfWin* window)
|
||||
{
|
||||
char* loading_text = "Loading older messages ...";
|
||||
GDateTime* timestamp = buffer_size(window->layout->buffer) != 0 ? buffer_get_entry(window->layout->buffer, 0)->time : g_date_time_new_now_local();
|
||||
buffer_prepend(window->layout->buffer, "-", 0, timestamp, NO_DATE, THEME_ROOMINFO, NULL, NULL, loading_text, NULL, NULL);
|
||||
win_redraw(window);
|
||||
}
|
||||
|
||||
gboolean
|
||||
win_has_active_subwin(ProfWin* window)
|
||||
{
|
||||
|
||||
@@ -77,6 +77,7 @@ void win_print_http_transfer(ProfWin* window, const char* const message, char* u
|
||||
|
||||
void win_newline(ProfWin* window);
|
||||
void win_redraw(ProfWin* window);
|
||||
void win_print_loading_history(ProfWin* window);
|
||||
int win_roster_cols(void);
|
||||
int win_occpuants_cols(void);
|
||||
void win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int indent);
|
||||
|
||||
Reference in New Issue
Block a user