mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
21 lines
732 B
TypeScript
21 lines
732 B
TypeScript
import { useConfigs } from 'containers/ConfigsContext'
|
|
import { useCallback } from 'react'
|
|
import { VisibleNodesGenerator } from 'utils/VisibleNodesGenerator'
|
|
import { SearchMode, searchModes } from '../../searchModes'
|
|
|
|
export function useOnSearch(
|
|
updateSearchKey: (searchKey: string) => void,
|
|
visibleNodesGenerator: VisibleNodesGenerator,
|
|
) {
|
|
const { restoreExpandedFolders } = useConfigs().value
|
|
return useCallback(
|
|
(searchKey: string, searchMode: SearchMode) => {
|
|
updateSearchKey(searchKey)
|
|
visibleNodesGenerator.search(
|
|
searchModes[searchMode].getSearchParams(searchKey),
|
|
restoreExpandedFolders,
|
|
)
|
|
},
|
|
[updateSearchKey, visibleNodesGenerator, restoreExpandedFolders],
|
|
)
|
|
}
|