Skip to content

Commit

Permalink
Merge pull request #321 from probablykasper/persist-history
Browse files Browse the repository at this point in the history
Persist history
  • Loading branch information
printfn authored Oct 25, 2024
2 parents 78e97fa + 1408c62 commit c9992cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
## Changelog

### Next

* Add `text` as a synonym for `string` (e.g. `5 to text`)
* Add `Cmd`+`K` / `Ctrl`+`K` or `Ctrl`+`L` to clear the web UI output
* Add `Cmd`+`k` / `Ctrl`+`k` or `Ctrl`+`l` to clear the web UI output
* Fix multiline input not being visible in the web UI
* Persist command history in the browser's local storage when using the web UI

### v1.5.3 (2024-10-06)

Expand Down
8 changes: 7 additions & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ function NewTabLink({ children, href }: { children: ReactNode; href: string }) {
);
}

const initialHistory = JSON.parse(localStorage.getItem('fend_history') || '[]');

export default function App({ widget = false }: { widget?: boolean }) {
const [currentInput, setCurrentInput] = useState('');
const [output, setOutput] = useState<ReactNode>(widget ? <></> : exampleContent);
const [history, setHistory] = useState<string[]>([]);
const [history, setHistory] = useState<string[]>(initialHistory);
useEffect(() => {
const history100 = history.slice(-100);
localStorage.setItem('fend_history', JSON.stringify(history100));
}, [history]);
const [variables, setVariables] = useState('');
const [navigation, setNavigation] = useState(0);
const [hint, setHint] = useState('');
Expand Down

0 comments on commit c9992cf

Please sign in to comment.