Skip to content

Commit

Permalink
Seek and destroy null values hiding in config
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinsonZ committed Dec 5, 2023
1 parent b3961e8 commit 97f951e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
20 changes: 0 additions & 20 deletions src/renderer/src/components/SlateImporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,26 +184,6 @@ export default function SlateImporter() {
)}
</Droppable>
)}
{/*
{createNote && (
<Droppable droppableId={"_IMPORTER"} isDropDisabled={true}>
{(provided, snapshot) => (
<div ref={provided.innerRef} {...provided.droppableProps}>
<>
<SlateCard
id={uuidv4()}
columnId="_IMPORTER"
index={index++}
type="note"
text="default text"
allowEdit={createNote}
/>
</>
{provided.placeholder}
</div>
)}
</Droppable>
)} */}
</>
);
}
11 changes: 9 additions & 2 deletions src/renderer/src/context/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,21 @@ export const SlateDataContext = createContext<FileDatabase>({
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";

const [data, dispatch] = useImmerReducer<FileDatabase, SlateAction>(
slateDataReducer,
{
columns: window.electronStore.get(KEY) || [],
columns: scrubNulls(window.electronStore.get(KEY) || []),
importerFiles: [],
}
);
Expand All @@ -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[]),
});
}
}
Expand Down

0 comments on commit 97f951e

Please sign in to comment.