Skip to content

Commit bc91f53

Browse files
committed
fix(url-state): include permissions loading in the custom-block deep-link paint hold
canAdmin reads false while the permissions context loads, so the hold must gate on permissionsLoading too; drop the blocksPending conjunct — it shares one query with useCanPublishCustomBlock, so isLoading already covers it.
1 parent 52b952a commit bc91f53

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

apps/sim/ee/custom-blocks/components/custom-blocks.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ export function CustomBlocks() {
2727
const workspaceId = typeof params?.workspaceId === 'string' ? params.workspaceId : undefined
2828
const workspacePermissions = useUserPermissionsContext()
2929
const canAdmin = canMutateWorkspaceSettingsSection('custom-blocks', workspacePermissions)
30+
const permissionsLoading = workspacePermissions.isLoading
3031

3132
const { data: canManage = false, isLoading } = useCanPublishCustomBlock(workspaceId)
32-
const { data: blocks = [], isPending: blocksPending } = useCustomBlocks(workspaceId)
33+
const { data: blocks = [] } = useCustomBlocks(workspaceId)
3334
const { data: workspaces = [] } = useWorkspacesQuery()
3435

3536
/** Publishing requires admin on a source workspace; viewing remains workspace-scoped. */
@@ -64,11 +65,12 @@ export function CustomBlocks() {
6465
const selectedBlock = selectedBlockId ? blocks.find((b) => b.id === selectedBlockId) : undefined
6566

6667
/**
67-
* Hold the first paint while a deep-linked id could still resolve, so a
68-
* valid link never flashes the list before jumping to the detail (a dead id
69-
* falls back to the list once the blocks load).
68+
* Hold the first paint while a deep-linked id could still resolve — the
69+
* blocks query (`isLoading`, shared with `useCanPublishCustomBlock`) and the
70+
* permissions context both gate the detail, so a valid link never flashes
71+
* the list before jumping to it. A dead id still falls back to the list.
7072
*/
71-
if (isLoading || (selectedBlockId && canAdmin && blocksPending)) return null
73+
if (isLoading || (selectedBlockId !== null && permissionsLoading)) return null
7274

7375
if (!canManage) {
7476
return (

0 commit comments

Comments
 (0)