refactor: shorten static history section code (#370)

This commit is contained in:
Brandon Keiji 2025-05-15 22:20:33 +00:00 committed by GitHub
parent 9efcb7741b
commit 28c3c3241d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 19 deletions

View File

@ -212,25 +212,17 @@ export const App = ({
* content is set it'll flush content to the terminal and move the area which it's "clearing" * content is set it'll flush content to the terminal and move the area which it's "clearing"
* down a notch. Without Static the area which gets erased and redrawn continuously grows. * down a notch. Without Static the area which gets erased and redrawn continuously grows.
*/} */}
<Static key={'static-key-' + staticKey} items={['header', ...history]}> <Static
{(item, index) => { key={staticKey}
if (item === 'header') { items={[
return ( <Box flexDirection="column" key="header">
<Box flexDirection="column" key={'header-' + index}>
<Header /> <Header />
<Tips /> <Tips />
</Box> </Box>,
); ...history.map((h) => <HistoryItemDisplay key={h.id} item={h} />),
} ]}
>
const historyItem = item as HistoryItem; {(item) => item}
return (
<HistoryItemDisplay
key={'history-' + historyItem.id}
item={historyItem}
/>
);
}}
</Static> </Static>
{pendingHistoryItem && ( {pendingHistoryItem && (
<HistoryItemDisplay <HistoryItemDisplay