From 97f951ec75fb87bdd7d31fd1850c4dd0190b1fd8 Mon Sep 17 00:00:00 2001 From: Zachary Robinson Date: Tue, 5 Dec 2023 10:46:47 -0500 Subject: [PATCH] Seek and destroy null values hiding in config --- src/renderer/src/components/SlateImporter.tsx | 20 ------------------- src/renderer/src/context/context.tsx | 11 ++++++++-- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/renderer/src/components/SlateImporter.tsx b/src/renderer/src/components/SlateImporter.tsx index 86a2fa9..d327b92 100644 --- a/src/renderer/src/components/SlateImporter.tsx +++ b/src/renderer/src/components/SlateImporter.tsx @@ -184,26 +184,6 @@ export default function SlateImporter() { )} )} -{/* - {createNote && ( - - {(provided, snapshot) => ( -
- <> - - - {provided.placeholder} -
- )} -
- )} */} ); } diff --git a/src/renderer/src/context/context.tsx b/src/renderer/src/context/context.tsx index c1e3da5..a46fb25 100644 --- a/src/renderer/src/context/context.tsx +++ b/src/renderer/src/context/context.tsx @@ -176,6 +176,13 @@ export const SlateDataContext = createContext({ importerFiles: [], }); +function scrubNulls(cols: SlateColumn[]) { + return cols.filter(c => c !== null).map(c => { + c.cards = c.cards.filter(card => card !== null); + return c + }) +} + export function SlateDataProvider(props: PropsWithChildren) { const { children } = props; const KEY = "slate_cols"; @@ -183,7 +190,7 @@ export function SlateDataProvider(props: PropsWithChildren) { const [data, dispatch] = useImmerReducer( slateDataReducer, { - columns: window.electronStore.get(KEY) || [], + columns: scrubNulls(window.electronStore.get(KEY) || []), importerFiles: [], } ); @@ -194,7 +201,7 @@ export function SlateDataProvider(props: PropsWithChildren) { if (newValue[KEY]) { dispatch({ type: "set_columns", - newColumns: newValue[KEY] as SlateColumn[], + newColumns: scrubNulls(newValue[KEY] as SlateColumn[]), }); } }