Skip to content

Commit a8b8f88

Browse files
fix: add try/catch around moveCardToBoard in dialog handler
Prevents isMoving state from getting stuck on network-level failures.
1 parent 34a3388 commit a8b8f88

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/components/Modals/MoveToAnotherBoardDialog.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,28 +181,32 @@ export const MoveToAnotherBoardDialog = memo(function MoveToAnotherBoardDialog({
181181
setIsMoving(true)
182182
setError(null)
183183

184-
const result = await moveCardToBoard(
185-
cardId,
186-
effectiveBoardId,
187-
effectiveStatusId,
188-
)
189-
190-
if (result.success) {
191-
const selectedBoard = availableBoards.find(
192-
(b) => b.id === effectiveBoardId,
184+
try {
185+
const result = await moveCardToBoard(
186+
cardId,
187+
effectiveBoardId,
188+
effectiveStatusId,
193189
)
194-
toast.success('Card moved', {
195-
description: `"${repoName}" has been moved to ${selectedBoard?.name ?? 'board'}.`,
196-
})
197-
setSelectedBoardId('')
198-
setSelectedStatusId('')
199-
onMoved(cardId)
200-
onClose()
201-
} else {
202-
setError(result.error || 'Failed to move card')
203-
}
204190

205-
setIsMoving(false)
191+
if (result.success) {
192+
const selectedBoard = availableBoards.find(
193+
(b) => b.id === effectiveBoardId,
194+
)
195+
toast.success('Card moved', {
196+
description: `"${repoName}" has been moved to ${selectedBoard?.name ?? 'board'}.`,
197+
})
198+
setSelectedBoardId('')
199+
setSelectedStatusId('')
200+
onMoved(cardId)
201+
onClose()
202+
} else {
203+
setError(result.error || 'Failed to move card')
204+
}
205+
} catch {
206+
setError('Failed to move card')
207+
} finally {
208+
setIsMoving(false)
209+
}
206210
}, [
207211
cardId,
208212
effectiveBoardId,

0 commit comments

Comments
 (0)