Skip to content

fix(perf): finish over-subscription audit (RoomConfig / ContactSelector / ContactItem)#379

Merged
mremond merged 1 commit intomainfrom
fix/over-subscription-polish
May 4, 2026
Merged

fix(perf): finish over-subscription audit (RoomConfig / ContactSelector / ContactItem)#379
mremond merged 1 commit intomainfrom
fix/over-subscription-polish

Conversation

@mremond
Copy link
Copy Markdown
Member

@mremond mremond commented May 4, 2026

Polish PR following #377 and #378. Closes the remaining low-/medium-impact callers identified in the audit so that no live component pulls a full useChat() / useRoom() / useAdmin() just for one or two values.

SDK

  • New useAdminPermissions() — focused subscription returning { isAdmin, hasUserCommands, canManageUser } only. Avoids the ~15 admin store subscriptions that useAdmin() makes (sessions, command queues, user/room lists, vhosts, pagination…).
  • Extracted USER_COMMANDS into a shared adminCommands.ts so useAdmin and useAdminPermissions share the source of truth.

App

  • ContactItem (each row in ContactList): swap useAdmin() for useAdminPermissions(). Each row previously had a full admin-store subscription, so any unrelated admin update re-rendered every contact in the list.
  • ContactSelector (mounted inside CreateRoomModal, CreateQuickChatModal, InviteToRoomModal, RoomMembersModal): drop useChat() in favour of a focused useChatStore selector for conversations.
  • RoomConfigModal: drop useAdmin() in favour of a useCallback wrapper around client.admin.fetchRoomOptions via useXMPP(). Only getRoomOptions was used.

…or / ContactItem)

Polish PR following #377 and #378.

SDK
- Add useAdminPermissions(): focused subscription returning { isAdmin,
  hasUserCommands, canManageUser } only — for components that gate UI on
  admin rights without needing the full admin store (sessions, command
  queues, user/room lists, vhosts, pagination, etc.).
- Extract USER_COMMANDS to a shared adminCommands.ts so useAdmin and
  useAdminPermissions share the source of truth.

App
- ContactItem (in ContactList): swap useAdmin() for useAdminPermissions().
  Each row in the contact list previously subscribed to the full admin
  store.
- ContactSelector: drop useChat() in favour of a focused useChatStore
  selector for conversations. Mounted inside several modals.
- RoomConfigModal: drop useAdmin() in favour of a useCallback wrapper
  around client.admin.fetchRoomOptions via useXMPP(). Only one action was
  used; no need for the full admin subscription set.

Tests updated for the new mock surface. Full suite passes.
@mremond mremond merged commit 12a8531 into main May 4, 2026
1 check passed
@mremond mremond deleted the fix/over-subscription-polish branch May 4, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant