Page MenuHomePhabricator

D4057.id12971.diff
No OneTemporary

D4057.id12971.diff

diff --git a/lib/hooks/search-sidebars.js b/lib/hooks/search-sidebars.js
--- a/lib/hooks/search-sidebars.js
+++ b/lib/hooks/search-sidebars.js
@@ -20,7 +20,7 @@
+listData: $ReadOnlyArray<SidebarInfo>,
+searchState: SidebarSearchState,
+setSearchState: SetState<SidebarSearchState>,
- +searchIndex: SearchIndex,
+ +onChangeSearchText: (text: string) => mixed,
} {
const [searchState, setSearchState] = React.useState({
text: '',
@@ -57,6 +57,16 @@
return index;
}, [sidebarInfos, userInfos, viewerID]);
+ const onChangeSearchText = React.useCallback(
+ (text: string) => {
+ setSearchState({
+ text,
+ results: new Set(searchIndex.getSearchResults(text)),
+ });
+ },
+ [searchIndex, setSearchState],
+ );
+
React.useEffect(() => {
setSearchState(curState => ({
...curState,
@@ -65,8 +75,13 @@
}, [searchIndex, setSearchState]);
return React.useMemo(
- () => ({ listData, searchState, setSearchState, searchIndex }),
- [listData, setSearchState, searchState, searchIndex],
+ () => ({
+ listData,
+ searchState,
+ setSearchState,
+ onChangeSearchText,
+ }),
+ [listData, setSearchState, searchState, onChangeSearchText],
);
}
diff --git a/native/chat/sidebar-list-modal.react.js b/native/chat/sidebar-list-modal.react.js
--- a/native/chat/sidebar-list-modal.react.js
+++ b/native/chat/sidebar-list-modal.react.js
@@ -35,18 +35,9 @@
listData,
searchState,
setSearchState,
- searchIndex,
+ onChangeSearchText,
} = useSearchSidebars(props.route.params.threadInfo);
- const onChangeSearchText = React.useCallback(
- (searchText: string) =>
- setSearchState({
- text: searchText,
- results: new Set(searchIndex.getSearchResults(searchText)),
- }),
- [searchIndex, setSearchState],
- );
-
const searchTextInputRef = React.useRef();
const setSearchTextInputRef = React.useCallback(
async (textInput: ?React.ElementRef<typeof TextInput>) => {
diff --git a/web/modals/chat/sidebar-list-modal.react.js b/web/modals/chat/sidebar-list-modal.react.js
--- a/web/modals/chat/sidebar-list-modal.react.js
+++ b/web/modals/chat/sidebar-list-modal.react.js
@@ -26,7 +26,7 @@
listData,
searchState,
setSearchState,
- searchIndex,
+ onChangeSearchText,
} = useSearchSidebars(threadInfo);
const { popModal } = useModalContext();
@@ -47,17 +47,6 @@
[popModal, listData],
);
- const onChangeSearchText = React.useCallback(
- (event: SyntheticEvent<HTMLInputElement>) => {
- const searchText = event.currentTarget.value;
- setSearchState({
- text: searchText,
- results: new Set(searchIndex.getSearchResults(searchText)),
- });
- },
- [searchIndex, setSearchState],
- );
-
const clearQuery = React.useCallback(
(event: SyntheticEvent<HTMLAnchorElement>) => {
event.preventDefault();
@@ -78,6 +67,14 @@
);
}
+ const handleOnChangeSearchText = React.useCallback(
+ (event: SyntheticEvent<HTMLInputElement>) => {
+ const { value } = event.currentTarget;
+ onChangeSearchText(value);
+ },
+ [onChangeSearchText],
+ );
+
return (
<Modal name="Sidebars" onClose={popModal}>
<div
@@ -93,7 +90,7 @@
type="text"
placeholder="Search sidebars"
value={searchState.text}
- onChange={onChangeSearchText}
+ onChange={handleOnChangeSearchText}
/>
{clearQueryButton}
</div>

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 5:34 PM (20 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605705
Default Alt Text
D4057.id12971.diff (3 KB)

Event Timeline