fix(ui): if deleting selected board, deselect it

This commit is contained in:
psychedelicious 2023-06-21 20:00:29 +10:00
parent f560a462a0
commit 26b75b85f7

View File

@ -14,6 +14,7 @@ import {
boardUpdated,
receivedBoards,
} from '../../../services/thunks/board';
import { api } from 'services/apiSlice';
export const boardsAdapter = createEntityAdapter<BoardDTO>({
selectId: (board) => board.board_id,
@ -92,6 +93,14 @@ const boardsSlice = createSlice({
console.log({ boardId });
boardsAdapter.removeOne(state, boardId);
});
builder.addMatcher(
api.endpoints.deleteBoard.matchFulfilled,
(state, action) => {
if (action.meta.arg.originalArgs === state.selectedBoardId) {
state.selectedBoardId = undefined;
}
}
);
},
});