mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: prevent unnecessary unmount
This commit is contained in:
parent
5f9af7dd7f
commit
391c3e457c
2 changed files with 18 additions and 30 deletions
|
|
@ -62,34 +62,6 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
[visibleNodes, goTo],
|
||||
)
|
||||
|
||||
function renderFiles(visibleNodes: VisibleNodes) {
|
||||
const { nodes } = visibleNodes
|
||||
const searchKey = visibleNodes.lastMatch?.match.searchKey
|
||||
const inSearch = searchKey !== ''
|
||||
if (inSearch && nodes.length === 0) {
|
||||
return (
|
||||
<Text marginTop={6} textAlign="center" color="text.gray">
|
||||
No results found.
|
||||
</Text>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<SizeObserver className={'files'}>
|
||||
{({ width = 0, height = 0 }) => (
|
||||
<ListView
|
||||
height={height}
|
||||
width={width}
|
||||
onNodeClick={onNodeClick}
|
||||
renderActions={renderActions}
|
||||
visibleNodes={visibleNodes}
|
||||
expandTo={expandTo}
|
||||
metaData={metaData}
|
||||
/>
|
||||
)}
|
||||
</SizeObserver>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cx(`file-explorer`, { freeze })}
|
||||
|
|
@ -114,7 +86,24 @@ const RawFileExplorer: React.FC<Props & ConnectorState> = function RawFileExplor
|
|||
onSearch={props.search}
|
||||
onFocus={props.onFocusSearchBar}
|
||||
/>
|
||||
{renderFiles(visibleNodes)}
|
||||
{visibleNodes.lastMatch?.match.searchKey !== '' && visibleNodes.nodes.length === 0 && (
|
||||
<Text marginTop={6} textAlign="center" color="text.gray">
|
||||
No results found.
|
||||
</Text>
|
||||
)}
|
||||
<SizeObserver className={'files'}>
|
||||
{({ width = 0, height = 0 }) => (
|
||||
<ListView
|
||||
height={height}
|
||||
width={width}
|
||||
onNodeClick={onNodeClick}
|
||||
renderActions={renderActions}
|
||||
visibleNodes={visibleNodes}
|
||||
expandTo={expandTo}
|
||||
metaData={metaData}
|
||||
/>
|
||||
)}
|
||||
</SizeObserver>
|
||||
</>
|
||||
)
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -304,7 +304,6 @@ class FlattenLayer extends CompressLayer {
|
|||
searchKey: string
|
||||
} | null,
|
||||
) => {
|
||||
// this.focusNode(null)
|
||||
this.shake(
|
||||
match
|
||||
? {
|
||||
|
|
|
|||
Loading…
Reference in a new issue