From 4970df30ba4b3e23326974a37df6e9347ce78cab Mon Sep 17 00:00:00 2001 From: Triston Date: Mon, 1 Apr 2024 23:01:09 -0500 Subject: [PATCH] (bug): fix type errors causing build failure issue #1 --- src/components/Board.tsx | 2 +- src/components/BoardEditor.tsx | 2 +- src/state/board.ts | 8 ++++---- src/state/mouse.ts | 5 ++++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Board.tsx b/src/components/Board.tsx index 57831e1..a341ea6 100644 --- a/src/components/Board.tsx +++ b/src/components/Board.tsx @@ -51,7 +51,7 @@ export function Board({ boardId }: { boardId: string }) { useEffect(() => { if (!boardsLoaded) return - const board = boards.find( + const board = boards?.find( (b) => String(b.id) === boardId || b.uuid === boardId ) if (!board) { diff --git a/src/components/BoardEditor.tsx b/src/components/BoardEditor.tsx index 463366d..b4e9a88 100644 --- a/src/components/BoardEditor.tsx +++ b/src/components/BoardEditor.tsx @@ -20,7 +20,7 @@ export function BoardEditorDrawer() { const { boardEditorOpen, setBoardEditorOpen } = useGlobal() return ( state === "exited" ? null : ( diff --git a/src/state/board.ts b/src/state/board.ts index a241a72..6f94232 100644 --- a/src/state/board.ts +++ b/src/state/board.ts @@ -8,7 +8,7 @@ import { useListsStore } from "./lists" export const useBoardStore = createStore( { board: null as Board | null }, - function (set, get) { + function(set, get) { const selectBoard = async (board: Board) => { const setTagsState = useBoardTagsStore.methods.setState const setListsState = useListsStore.methods.setState @@ -29,7 +29,7 @@ export const useBoardStore = createStore( const board = get().board! const newBoard = { ...board, ...payload } const res = await db.updateBoard(newBoard) - updateBoards(boards.map((b) => (b.id === res.id ? newBoard : b))) + updateBoards(boards?.map((b) => (b.id === res.id ? newBoard : b)) ?? []) set({ board: res }) } const deleteBoard = async () => { @@ -52,7 +52,7 @@ export const useBoardStore = createStore( db.deleteBoard(board), ]) - updateBoards(boards.filter((b) => b.id !== board.id)) + updateBoards(boards?.filter((b) => b.id !== board.id) ?? []) set({ board: null }) navigate("/") } @@ -60,7 +60,7 @@ export const useBoardStore = createStore( const { boards, updateBoards } = useGlobal() const board = get().board! const newBoard = await db.archiveBoard(board) - updateBoards(boards.map((b) => (b.id === board.id ? newBoard : b))) + updateBoards(boards?.map((b) => (b.id === board.id ? newBoard : b)) ?? []) navigate("/") } const restoreBoard = async () => { diff --git a/src/state/mouse.ts b/src/state/mouse.ts index d82814a..e927aab 100644 --- a/src/state/mouse.ts +++ b/src/state/mouse.ts @@ -6,5 +6,8 @@ type MouseContext = { setValue: (payload: Vector2) => void } -export const MouseCtx = createContext(null) +export const MouseCtx = createContext({ + current: { x: 0, y: 0 }, + setValue: (_payload: Vector2) => { } +}) export const useMouse = () => useContext(MouseCtx)