,
>([]);
const searchRef = React.useRef();
React.useEffect(() => {
searchRef.current?.focus();
}, []);
const onChangeSearchText = React.useCallback(
(text: string) => {
const results = searchIndex.getSearchResults(text);
setSearchText(text);
const threadInfoResults = reorderThreadSearchResults(
onScreenThreadInfos,
results,
);
setSearchResults(threadInfoResults);
},
[searchIndex, onScreenThreadInfos],
);
const threads = React.useMemo(
() => (searchText ? searchResults : onScreenThreadInfos),
[searchText, onScreenThreadInfos, searchResults],
);
const threadPickerContent = React.useMemo(() => {
const options = threads.map(threadInfo => (
));
if (options.length === 0 && searchText.length > 0) {
return (
No results for {searchText}
);
} else {
return options;
}
}, [threads, createNewEntry, modalProps.onClose, searchText]);
return (
);
}
export default ThreadPickerModal;