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.
Description
useSubscriptionstriggers 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 entirestate.serverobject:Since
state.servercontains fields likeconnecting,loading, and others that change as the connection state changes, selecting the entirestate.serverobject causes theuseEffectinsideuseSubscriptions.tsto trigger on every connection status change because its dependency array includesserver: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.tsto select only the server URL instead of the entire server state:This ensures that the
useEffectis only triggered when the active server actually changes, and not when the connection state of the current server transitions.