fix(ui): address PR review on WIN_CHAT scroll handling
All checks were successful
CI Code / Check coding style (pull_request) Successful in 36s
CI Code / Check spelling (pull_request) Successful in 19s
CI Code / Code Coverage (pull_request) Successful in 2m40s
CI Code / Linux (debian) (pull_request) Successful in 4m38s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m53s
CI Code / Linux (arch) (pull_request) Successful in 5m41s

- 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.
This commit is contained in:
2026-05-16 17:57:28 +03:00
parent 0f24910685
commit ac7d6c31f0

View File

@@ -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;
}