From 4ec930c8f02cc01998acdf3db25cdd836c47a61d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 23 Jul 2026 21:25:39 +0300 Subject: [PATCH] chatgui: fix dual selection highlight and missing online count - channellist.cpp: selectionChanged guard now checks currentIndex().row() is within model->rowCount() to avoid re-selecting stale index after model clear, which caused both channels to stay blue when switching. - chat_sync.c: cs_refresh_channels now posts CHANNEL_PEERS_ONLINE for all channels after loading, fixing online count showing only on the last connected group. --- tools/chatgui/src/channellist.cpp | 3 ++- tools/chatgui/transport/chat_sync.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/chatgui/src/channellist.cpp b/tools/chatgui/src/channellist.cpp index b69b30ac..4a66786a 100644 --- a/tools/chatgui/src/channellist.cpp +++ b/tools/chatgui/src/channellist.cpp @@ -56,7 +56,8 @@ protected: } void selectionChanged(const QItemSelection& sel, const QItemSelection& desel) override { QListView::selectionChanged(sel, desel); - if (selectionModel() && !selectionModel()->hasSelection() && currentIndex().isValid()) + if (selectionModel() && !selectionModel()->hasSelection() && currentIndex().isValid() + && currentIndex().row() < model()->rowCount()) selectionModel()->select(currentIndex(), QItemSelectionModel::ClearAndSelect); } diff --git a/tools/chatgui/transport/chat_sync.c b/tools/chatgui/transport/chat_sync.c index 34de5e52..a9f4241a 100644 --- a/tools/chatgui/transport/chat_sync.c +++ b/tools/chatgui/transport/chat_sync.c @@ -508,6 +508,9 @@ static void cs_refresh_channels(struct chat_sync* cs) { memcpy(&cs->channels[i].peer_ids[j], peer_buf + 2 + j * 8, 8); } } + + for (int i = 0; i < cs->channel_count; i++) + cs_post_channel_online(cs, cs->channels[i].channel_id); } static void refresh_timer_cb(void* arg) {