Skip to content

Commit c0e20b6

Browse files
committed
fix(queries): add userId to superuser query key for cache isolation
1 parent ab9ddb2 commit c0e20b6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/settings-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export function SettingsModal({ open, onOpenChange }: SettingsModalProps) {
211211
const { data: generalSettings } = useGeneralSettings()
212212
const { data: subscriptionData } = useSubscriptionData({ enabled: isBillingEnabled })
213213
const { data: ssoProvidersData, isLoading: isLoadingSSO } = useSSOProviders()
214-
const { data: superUserData } = useSuperUserStatus(Boolean(session?.user?.id))
214+
const { data: superUserData } = useSuperUserStatus(session?.user?.id)
215215

216216
const activeOrganization = organizationsData?.activeOrganization
217217
const { config: permissionConfig } = usePermissionConfig()

apps/sim/hooks/queries/user-profile.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const logger = createLogger('UserProfileQuery')
99
export const userProfileKeys = {
1010
all: ['userProfile'] as const,
1111
profile: () => [...userProfileKeys.all, 'profile'] as const,
12-
superUser: () => [...userProfileKeys.all, 'superUser'] as const,
12+
superUser: (userId?: string) => [...userProfileKeys.all, 'superUser', userId ?? ''] as const,
1313
}
1414

1515
/**
@@ -134,13 +134,13 @@ async function fetchSuperUserStatus(): Promise<SuperUserStatus> {
134134

135135
/**
136136
* Hook to fetch superuser status
137+
* @param userId - User ID for cache isolation (required for proper per-user caching)
137138
*/
138-
export function useSuperUserStatus(enabled = true) {
139+
export function useSuperUserStatus(userId?: string) {
139140
return useQuery({
140-
queryKey: userProfileKeys.superUser(),
141+
queryKey: userProfileKeys.superUser(userId),
141142
queryFn: fetchSuperUserStatus,
142-
enabled,
143+
enabled: Boolean(userId),
143144
staleTime: 5 * 60 * 1000, // 5 minutes - superuser status rarely changes
144-
placeholderData: keepPreviousData,
145145
})
146146
}

0 commit comments

Comments
 (0)