From ac7d6c31f05df3e9e9df1dd9c8984301b81a2e25 Mon Sep 17 00:00:00 2001 From: "jabber.developer2" Date: Sat, 16 May 2026 17:57:28 +0300 Subject: [PATCH] fix(ui): address PR review on WIN_CHAT scroll handling - Drop DB_RESPONSE_ERROR -> REACHED_BOTTOM in win_page_down: a transient backend error (e.g. sqlite lock) should not force the scroll state forward, or the user would get stuck mid-conversation expecting more rows that did not load. - Trim the _win_printf comment to a single WHY line; the rest belongs in the originating commit message. --- src/ui/window.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ui/window.c b/src/ui/window.c index bf84294f..51f36872 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -813,9 +813,7 @@ win_page_down(ProfWin* window, int scroll_size) auto_gchar gchar* start = g_date_time_format_iso8601(last_entry->time); auto_gchar gchar* end_date = g_date_time_format_iso8601(now); db_history_result_t db_response = chatwin_db_history((ProfChatWin*)window, start, end_date, FALSE); - // Treat transient DB error (e.g. no active backend) the same - // as EMPTY: no rows can be fetched, so stop indicating [SCROLLED]. - if (db_response == DB_RESPONSE_EMPTY || db_response == DB_RESPONSE_ERROR) + if (db_response == DB_RESPONSE_EMPTY) *scroll_state = WIN_SCROLL_REACHED_BOTTOM; // similar to page_up (see explanation there) @@ -1811,13 +1809,9 @@ static void _win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...) { - /* While the user is scrolled, bump the unread indicator. WIN_CHAT - * skips the buffer/render only when the DB will preserve the message - * verbatim — chatwin_db_history on scroll-down will replay it. When - * the DB is off/redact/dead we cannot recover, so fall through and - * append to the buffer just like non-chat windows. */ if (window->layout->paged && wins_is_current(window)) { window->layout->unread_msg++; + // Skip buffer only when DB can replay the message on scroll-down. if (window->type == WIN_CHAT && log_database_can_recover_messages()) { return; }