| 101 | }; |
| 102 | |
| 103 | const addHistoryEntry = (entry: IHistory) => { |
| 104 | if ( |
| 105 | !history.some( |
| 106 | ({ inputText, outputText }) => |
| 107 | inputText === entry.inputText && outputText === entry.outputText |
| 108 | ) && |
| 109 | !prevquery.some( |
| 110 | ({ previnput, prevoutput }) => |
| 111 | previnput === entry.inputText && prevoutput === entry.outputText |
| 112 | ) |
| 113 | ) { |
| 114 | setHistory([...history, entry]); |
| 115 | } |
| 116 | const newhistory: prev = { |
| 117 | previnput: entry.inputText, |
| 118 | prevoutput: entry.outputText, |
| 119 | }; |
| 120 | setPrevquery([...prevquery, newhistory]); |
| 121 | }; |
| 122 | |
| 123 | function safeJSONParse(str: string) { |
| 124 | try { |