From 29452fcead6a4c52c781232a60ce93481fa5c28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sat, 15 Aug 2026 13:18:49 +0200 Subject: [PATCH] [UserList] Re-sort when a user's online state changes setUserOnline() flipped the online flag but never re-sorted, so a buddy who went offline kept the position they had while online and stayed at the top of the list. Re-sort (and re-apply the filter) whenever the flag actually changes, mirroring processUserInfo(). Took 10 minutes --- .../widgets/server/user/user_list_widget.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp b/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp index 73da39809..0dc57c9f8 100644 --- a/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp +++ b/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp @@ -1287,6 +1287,13 @@ void UserListWidget::setUserOnline(const QString &userName, bool online) return; } + // No state change: nothing to re-sort. This also keeps the per-user + // presence broadcasts (userJoinedOnline fires for every online user) cheap + // when the row already carries the right flag. + if (twi->data(0, UserListRoles::Online).toBool() == online) { + return; + } + twi->setOnline(online); if (online) { ++onlineCount; @@ -1294,6 +1301,15 @@ void UserListWidget::setUserOnline(const QString &userName, bool online) --onlineCount; } updateCount(); + + // Online users sort above offline users (UserListTWI::operator<), so a + // flag change moves the row: re-sort so e.g. a buddy who went offline no + // longer stays pinned at the top of the list. + if (!bulkLoading) { + sortItems(); + applyFilter(); + userTree->viewport()->update(); + } } void UserListWidget::updateCount()