Skip to content

Commit 7ee27fe

Browse files
fix(tables): wait for permissions before announcing table locks
The lock announcement fires once per table, so a canAdmin that is still false because permissions have not resolved permanently drops the toast's Lock settings action. Arm the one-shot on the permissions decision rather than on table resolution.
1 parent 7e3a19e commit 7ee27fe

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/tables/[tableId]

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,17 @@ export function Table({
639639
[tableData, canOpenLockSettings]
640640
)
641641

642-
// Announce the lock state once per table on open. Marked announced as soon as
643-
// the table resolves, so an admin who just set locks isn't toasted about them.
642+
// Announce the lock state once per table on open. Unlike the re-rendering
643+
// permission gates, this fires once and can't self-correct, so it waits for
644+
// `canAdmin` to settle instead of treating loading as permitted.
644645
const announcedLockTableIdRef = useRef<string | null>(null)
645646
useEffect(() => {
646-
if (!tableData || announcedLockTableIdRef.current === tableData.id) return
647+
if (!tableData || userPermissions.isLoading) return
648+
if (announcedLockTableIdRef.current === tableData.id) return
647649
announcedLockTableIdRef.current = tableData.id
648650
if (lockedNouns(tableData.locks).length === 0) return
649651
showBlockedToast('status')
650-
}, [tableData, showBlockedToast])
652+
}, [tableData, userPermissions.isLoading, showBlockedToast])
651653

652654
const headerActions = useMemo(() => {
653655
if (!tableData) return undefined

0 commit comments

Comments
 (0)