diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/buffer.c | 8 | ||||
-rw-r--r-- | src/ui/buffer.h | 1 | ||||
-rw-r--r-- | src/ui/window.c | 18 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 0203c35c..553dc325 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -153,6 +153,14 @@ buffer_remove_entry_by_id(ProfBuff buffer, const char* const id) } } +void +buffer_remove_entry(ProfBuff buffer, int entry) +{ + GSList* node = g_slist_nth(buffer->entries, entry); + _free_entry(node->data); + buffer->entries = g_slist_delete_link(buffer->entries, node); +} + gboolean buffer_mark_received(ProfBuff buffer, const char* const id) { diff --git a/src/ui/buffer.h b/src/ui/buffer.h index e3e79655..535df882 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -72,6 +72,7 @@ void buffer_free(ProfBuff buffer); void buffer_append(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const barejid, const char* const message, DeliveryReceipt* receipt, const char* const id); void buffer_prepend(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const barejid, const char* const message, DeliveryReceipt* receipt, const char* const id); void buffer_remove_entry_by_id(ProfBuff buffer, const char* const id); +void buffer_remove_entry(ProfBuff buffer, int entry); int buffer_size(ProfBuff buffer); ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry); ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char* const id); diff --git a/src/ui/window.c b/src/ui/window.c index 4794e5c0..1dedb1d8 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -602,11 +602,19 @@ win_page_up(ProfWin* window) if (*page_start == -page_space && prefs_get_boolean(PREF_MAM) && window->type == WIN_CHAT) { ProfChatWin* chatwin = (ProfChatWin*) window; - if (!chatwin_old_history(chatwin)) { - cons_show("Fetched mam"); - iq_mam_request_older(chatwin); - } else { - cons_show("Showed history"); + ProfBuffEntry* first_entry = buffer_size(window->layout->buffer) != 0 ? buffer_get_entry(window->layout->buffer, 0) : NULL; + char* loading_text = "Loading older messages ..."; + + // Don't do anything if still fetching mam messages + if (first_entry && !(first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, loading_text) == 0)) { + if (!chatwin_old_history(chatwin)) { + 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); + iq_mam_request_older(chatwin); + } else { + cons_show("Showed history"); + } } } |