(inputValue: JSONContent)
| 44 | } |
| 45 | |
| 46 | function add(inputValue: JSONContent) { |
| 47 | setPendingInput(emptyJsonContent()); |
| 48 | |
| 49 | if ( |
| 50 | JSON.stringify(inputHistory[inputHistory.length - 1]) === |
| 51 | JSON.stringify(inputValue) |
| 52 | ) { |
| 53 | setCurrentIndex(inputHistory.length); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | setCurrentIndex(Math.min(inputHistory.length + 1, MAX_HISTORY_LENGTH)); |
| 58 | setInputHistory((prev) => { |
| 59 | return [...prev, inputValue].slice(-MAX_HISTORY_LENGTH); |
| 60 | }); |
| 61 | setLocalStorage( |
| 62 | `inputHistory_${historyKey}`, |
| 63 | [...inputHistory, inputValue].slice(-MAX_HISTORY_LENGTH), |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | const prevRef = useUpdatingRef(prev, [inputHistory]); |
| 68 | const nextRef = useUpdatingRef(next, [inputHistory]); |
nothing calls this directly
no test coverage detected