Skip to content

Commit 4b6b39e

Browse files
committed
ack PR comment
1 parent 1cea64d commit 4b6b39e

File tree

1 file changed

+4
-6
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/general

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,15 @@ export function General({ onOpenChange }: GeneralProps) {
7777

7878
const [uploadError, setUploadError] = useState<string | null>(null)
7979

80-
const [snapToGridValue, setSnapToGridValue] = useState(settings?.snapToGridSize ?? 0)
80+
const [localSnapValue, setLocalSnapValue] = useState<number | null>(null)
81+
const snapToGridValue = localSnapValue ?? settings?.snapToGridSize ?? 0
8182

8283
useEffect(() => {
8384
if (profile?.name) {
8485
setName(profile.name)
8586
}
8687
}, [profile?.name])
8788

88-
useEffect(() => {
89-
setSnapToGridValue(settings?.snapToGridSize ?? 0)
90-
}, [settings?.snapToGridSize])
91-
9289
useEffect(() => {
9390
const fetchSuperUserStatus = async () => {
9491
try {
@@ -242,14 +239,15 @@ export function General({ onOpenChange }: GeneralProps) {
242239
}
243240

244241
const handleSnapToGridChange = (value: number[]) => {
245-
setSnapToGridValue(value[0])
242+
setLocalSnapValue(value[0])
246243
}
247244

248245
const handleSnapToGridCommit = async (value: number[]) => {
249246
const newValue = value[0]
250247
if (newValue !== settings?.snapToGridSize && !updateSetting.isPending) {
251248
await updateSetting.mutateAsync({ key: 'snapToGridSize', value: newValue })
252249
}
250+
setLocalSnapValue(null)
253251
}
254252

255253
const handleTrainingControlsChange = async (checked: boolean) => {

0 commit comments

Comments
 (0)