Page MenuHomePhabricator

D8291.diff
No OneTemporary

D8291.diff

diff --git a/web/modals/search/message-search-modal.react.js b/web/modals/search/message-search-modal.react.js
--- a/web/modals/search/message-search-modal.react.js
+++ b/web/modals/search/message-search-modal.react.js
@@ -20,17 +20,23 @@
import Modal from '../modal.react.js';
type ContentProps = {
- +query: string,
+threadInfo: ThreadInfo,
};
-function MessageSearchModalContent(props: ContentProps): React.Node {
- const { query, threadInfo } = props;
+function MessageSearchModal(props: ContentProps): React.Node {
+ const { threadInfo } = props;
const [lastID, setLastID] = React.useState();
const [searchResults, setSearchResults] = React.useState([]);
const [endReached, setEndReached] = React.useState(false);
+ const { getQuery, setQuery, clearQuery } = useMessageSearchContext();
+
+ const query = React.useMemo(
+ () => getQuery(threadInfo.id),
+ [getQuery, threadInfo.id],
+ );
+
const appendSearchResults = React.useCallback(
(newMessages: $ReadOnlyArray<RawMessageInfo>, end: boolean) => {
setSearchResults(oldMessages => [...oldMessages, ...newMessages]);
@@ -127,38 +133,6 @@
);
}, [query, endReached, modifiedItems.length]);
- return (
- <div className={css.content} ref={messageContainerRef}>
- {messages}
- {footer}
- </div>
- );
-}
-
-function oldestMessageID(data: $ReadOnlyArray<ChatMessageItem>) {
- for (let i = data.length - 1; i >= 0; i--) {
- if (data[i].itemType === 'message' && data[i].messageInfo.id) {
- return data[i].messageInfo.id;
- }
- }
- return undefined;
-}
-
-type Props = {
- +threadInfo: ThreadInfo,
-};
-
-function MessageSearchModal(props: Props): React.Node {
- const { threadInfo } = props;
- const { popModal } = useModalContext();
-
- const { getQuery, setQuery, clearQuery } = useMessageSearchContext();
-
- const query = React.useMemo(
- () => getQuery(threadInfo.id),
- [getQuery, threadInfo.id],
- );
-
const [input, setInput] = React.useState(query);
const onPressSearch = React.useCallback(
@@ -166,9 +140,6 @@
[setQuery, input, threadInfo.id],
);
- const { uiName } = useResolvedThreadInfo(threadInfo);
- const searchPlaceholder = `Searching in ${uiName}`;
-
const clearQueryWrapper = React.useCallback(
() => clearQuery(threadInfo.id),
[clearQuery, threadInfo.id],
@@ -183,6 +154,10 @@
[onPressSearch],
);
+ const { uiName } = useResolvedThreadInfo(threadInfo);
+ const searchPlaceholder = `Searching in ${uiName}`;
+ const { popModal } = useModalContext();
+
return (
<Modal name="Search Message" onClose={popModal} size="large">
<div className={css.container}>
@@ -202,10 +177,22 @@
Search
</Button>
</div>
- <MessageSearchModalContent threadInfo={threadInfo} query={query} />
+ <div className={css.content} ref={messageContainerRef}>
+ {messages}
+ {footer}
+ </div>
</div>
</Modal>
);
}
+function oldestMessageID(data: $ReadOnlyArray<ChatMessageItem>) {
+ for (let i = data.length - 1; i >= 0; i--) {
+ if (data[i].itemType === 'message' && data[i].messageInfo.id) {
+ return data[i].messageInfo.id;
+ }
+ }
+ return undefined;
+}
+
export default MessageSearchModal;

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 4:31 PM (20 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585483
Default Alt Text
D8291.diff (3 KB)

Event Timeline