Skip to content

Bug: Room list query flickers on every connection state change #7437

Description

@Shevilll

Description

useSubscriptions triggers active WatermelonDB room list queries every time connection status transitions (e.g., from connecting to connected, or loading to not loading), even if subscription records are unmodified. This leads to room list query flickering on every connection state change.

Cause

In app/views/RoomsListView/hooks/useSubscriptions.ts, the hook selects the entire state.server object:

const server = useAppSelector(state => state.server);

Since state.server contains fields like connecting, loading, and others that change as the connection state changes, selecting the entire state.server object causes the useEffect inside useSubscriptions.ts to trigger on every connection status change because its dependency array includes server:

}, [isGrouping, sortBy, useRealName, showUnread, showFavorites, groupByType, roles, server]);

This forces the hook to re-query WatermelonDB and recreate the subscription, causing a visible flicker in the room list on every connection state transition.

Solution

Narrow the selector in useSubscriptions.ts to select only the server URL instead of the entire server state:

const server = useAppSelector(state => state.server.server);

This ensures that the useEffect is only triggered when the active server actually changes, and not when the connection state of the current server transitions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions