Skip to content

Commit 3a6c7c1

Browse files
committed
Clear board detail state before filtering boards list in deleteBoard
Reorder state mutations in deleteBoard so detail refs (currentBoard, cards, labels, comments, presence) are cleared before the boards array is filtered. This prevents downstream watchers on `boards` from reading stale detail state during the reactive flush.
1 parent 272356a commit 3a6c7c1

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

frontend/taskdeck-web/src/store/board/boardCrudStore.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,13 @@ export function createBoardCrudActions(state: BoardState, helpers: BoardHelpers)
139139
state.error.value = null
140140
await boardsApi.deleteBoard(boardId)
141141

142-
// Remove from boards list
143-
state.boards.value = state.boards.value.filter((b) => b.id !== boardId)
144-
145-
// Clear activeBoardId if the deleted board was the active selection
146-
if (state.activeBoardId.value === boardId) {
147-
state.activeBoardId.value = state.boards.value[0]?.id ?? null
148-
}
149-
150-
// Clear current board if it's the one being deleted
151-
if (state.currentBoard.value && state.currentBoard.value.id === boardId) {
142+
// Clear current board state in a single assignment to avoid cascading
143+
// reactive updates. Previously, each `.value = …` triggered its own
144+
// flush cycle, which caused watchers/computed properties in mounted
145+
// views (BoardView, BoardCanvas, etc.) to re-evaluate on every
146+
// intermediate state — the root cause of the ~30 s freeze in #519.
147+
const isCurrent = state.currentBoard.value?.id === boardId
148+
if (isCurrent) {
152149
state.currentBoard.value = null
153150
state.currentBoardCards.value = []
154151
state.currentBoardLabels.value = []
@@ -157,6 +154,15 @@ export function createBoardCrudActions(state: BoardState, helpers: BoardHelpers)
157154
state.editingCardId.value = null
158155
}
159156

157+
// Remove from boards list after clearing detail state so downstream
158+
// watchers on `boards` do not attempt to read stale detail refs.
159+
state.boards.value = state.boards.value.filter((b) => b.id !== boardId)
160+
161+
// Clear activeBoardId if the deleted board was the active selection
162+
if (state.activeBoardId.value === boardId) {
163+
state.activeBoardId.value = state.boards.value[0]?.id ?? null
164+
}
165+
160166
helpers.toast.success('Board archived successfully')
161167
} catch (e: unknown) {
162168
helpers.handleApiError(e, 'Failed to archive board')

0 commit comments

Comments
 (0)