diff --git a/src/App.tsx b/src/App.tsx index 7e73d53..49523a6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -93,12 +93,14 @@ function App() { }; const handleSubClick = (topic: string, index: number) => { - let text = getTopicChildren(topic)[index]; - let filtered = codes.filter((code: Code) => code.type === topic && code.text === text); - if (filtered.length == 1) { - let payload: string = generatePayload(filtered[0]); - setSubTopic(""); - invoke('type_str', {input: payload}); + if (codes){ + let text = getTopicChildren(topic)[index]; + let filtered = codes.filter((code: Code) => code.type === topic && code.text === text); + if (filtered.length == 1) { + let payload: string = generatePayload(filtered[0]); + setSubTopic(""); + invoke('type_str', {input: payload}); + } } }; @@ -132,14 +134,16 @@ function App() { } const handleTopicClick = (type: string) => { - let filtered = codes.filter((code: Code) => code.type === type); - if (filtered.length == 1) { - let assembledStr: string = generatePayload(filtered[0]); - setSubTopic(""); - invoke('type_str', {input: assembledStr}); - }else{ - // Open Submenu for type - setSubTopic(type); + if (codes) { + let filtered = codes.filter((code: Code) => code.type === type); + if (filtered.length == 1) { + let assembledStr: string = generatePayload(filtered[0]); + setSubTopic(""); + invoke('type_str', {input: assembledStr}); + }else{ + // Open Submenu for type + setSubTopic(type); + } } }; @@ -167,7 +171,6 @@ function App() { })} ); - // TODO: This isn't returning as expected, use an object to append to then return the compiled list }else{ return (
); }