mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Merge pull request #1905 from H3rnand3zzz/fix/history-lag
Improve history paging performance
This commit is contained in:
commit
e609b70545
@ -53,7 +53,7 @@
|
||||
#include "ui/window.h"
|
||||
#include "ui/buffer.h"
|
||||
|
||||
#define BUFF_SIZE 1200
|
||||
#define BUFF_SIZE 200
|
||||
|
||||
struct prof_buff_t
|
||||
{
|
||||
|
@ -75,6 +75,9 @@ static void _win_print_internal(ProfWin* window, const char* show_char, int pad_
|
||||
int flags, theme_item_t theme_item, const char* const from, const char* const message, DeliveryReceipt* receipt);
|
||||
static void _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pad_indent);
|
||||
|
||||
static gboolean _reached_top_of_database = FALSE;
|
||||
static gboolean _reached_bottom_of_database = FALSE;
|
||||
|
||||
int
|
||||
win_roster_cols(void)
|
||||
{
|
||||
@ -622,6 +625,7 @@ win_free(ProfWin* window)
|
||||
void
|
||||
win_page_up(ProfWin* window)
|
||||
{
|
||||
_reached_bottom_of_database = FALSE;
|
||||
int rows = getmaxy(stdscr);
|
||||
int y = getcury(window->layout->win);
|
||||
int page_space = rows - 4;
|
||||
@ -635,7 +639,11 @@ win_page_up(ProfWin* window)
|
||||
|
||||
// Don't do anything if still fetching mam messages
|
||||
if (first_entry && !(first_entry->theme_item == THEME_ROOMINFO && g_strcmp0(first_entry->message, LOADING_MESSAGE) == 0)) {
|
||||
if (!chatwin_db_history(chatwin, NULL, NULL, TRUE) && prefs_get_boolean(PREF_MAM)) {
|
||||
if (!_reached_top_of_database) {
|
||||
_reached_top_of_database = !chatwin_db_history(chatwin, NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (_reached_top_of_database && prefs_get_boolean(PREF_MAM)) {
|
||||
win_print_loading_history(window);
|
||||
iq_mam_request_older(chatwin);
|
||||
}
|
||||
@ -658,6 +666,7 @@ win_page_up(ProfWin* window)
|
||||
void
|
||||
win_page_down(ProfWin* window)
|
||||
{
|
||||
_reached_top_of_database = FALSE;
|
||||
int rows = getmaxy(stdscr);
|
||||
int y = getcury(window->layout->win);
|
||||
int page_space = rows - 4;
|
||||
@ -673,7 +682,9 @@ win_page_down(ProfWin* window)
|
||||
GDateTime* now = g_date_time_new_now_local();
|
||||
gchar* end = g_date_time_format_iso8601(now);
|
||||
// end is free'd inside
|
||||
chatwin_db_history((ProfChatWin*)window, start, end, FALSE);
|
||||
if (!_reached_bottom_of_database && !chatwin_db_history((ProfChatWin*)window, start, end, FALSE)) {
|
||||
_reached_bottom_of_database = TRUE;
|
||||
}
|
||||
|
||||
g_date_time_unref(now);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user