Query sidebar directs and shared rooms separately

Load visible direct memberships ordered by room recency and other
rooms ordered by name, instead of hydrating every membership and
splitting them in Ruby.

Fixes #307.

Co-authored-by: Thomas Klemm <github@tklemm.eu>
This commit is contained in:
Cursor Agent
2026-10-05 12:35:35 +00:00
parent 254dd1d46f
commit fbeb1ae993
3 changed files with 25 additions and 2 deletions
+3 -2
View File
@@ -2,8 +2,9 @@ class Users::SidebarsController < ApplicationController
DIRECT_PLACEHOLDERS = 20
def show
@direct_memberships, @other_memberships = Current.user.memberships.visible.with_ordered_room.partition { |membership| membership.room.direct? }
@direct_memberships = @direct_memberships.sort_by { |membership| membership.room.updated_at }.reverse
visible_memberships = Current.user.memberships.visible
@direct_memberships = visible_memberships.with_direct_rooms
@other_memberships = visible_memberships.without_direct_rooms.with_ordered_room
@direct_placeholder_users = find_direct_placeholder_users
end