Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525991
D7773.id26718.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7773.id26718.diff
View Options
diff --git a/native/chat/chat.react.js b/native/chat/chat.react.js
--- a/native/chat/chat.react.js
+++ b/native/chat/chat.react.js
@@ -68,7 +68,10 @@
type ScreenParamList,
type ChatParamList,
type ChatTopTabsParamList,
+ MessageSearchRouteName,
} from '../navigation/route-names.js';
+import MessageSearch from '../search/message-search.react.js';
+import SearchHeader from '../search/search-header.react.js';
import { useColors, useStyles } from '../themes/colors.js';
const unboundStyles = {
@@ -268,6 +271,14 @@
headerTitle: 'Delete chat',
headerBackTitleVisible: false,
};
+const messageSearchOptions = {
+ // eslint-disable-next-line react/display-name
+ headerTitle: () => <SearchHeader />,
+ headerBackTitleVisible: false,
+ headerTitleContainerStyle: {
+ width: '100%',
+ },
+};
const messageResultsScreenOptions = {
headerTitle: 'Pinned Messages',
headerBackTitleVisible: false,
@@ -385,6 +396,11 @@
component={MessageResultsScreen}
options={messageResultsScreenOptions}
/>
+ <Chat.Screen
+ name={MessageSearchRouteName}
+ component={MessageSearch}
+ options={messageSearchOptions}
+ />
</Chat.Navigator>
<MessageStorePruner />
<ThreadScreenPruner />
diff --git a/native/navigation/route-names.js b/native/navigation/route-names.js
--- a/native/navigation/route-names.js
+++ b/native/navigation/route-names.js
@@ -34,6 +34,7 @@
import type { VideoPlaybackModalParams } from '../media/video-playback-modal.react.js';
import type { CustomServerModalParams } from '../profile/custom-server-modal.react.js';
import type { RelationshipListItemTooltipModalParams } from '../profile/relationship-list-item-tooltip-modal.react.js';
+import type { MessageSearchParams } from '../search/message-search.react.js';
export const ActionResultModalRouteName = 'ActionResultModal';
export const AddUsersModalRouteName = 'AddUsersModal';
@@ -97,6 +98,7 @@
export const CoolOrNerdModeSelectionRouteName = 'CoolOrNerdModeSelection';
export const ConnectEthereumRouteName = 'ConnectEthereum';
export const ExistingEthereumAccountRouteName = 'ExistingEthereumAccount';
+export const MessageSearchRouteName = 'MessageSearch';
export type RootParamList = {
+LoggedOutModal: void,
@@ -161,6 +163,7 @@
+DeleteThread: DeleteThreadParams,
+FullScreenThreadMediaGallery: FullScreenThreadMediaGalleryParams,
+MessageResultsScreen: MessageResultsScreenParams,
+ +MessageSearch: MessageSearchParams,
};
export type ChatTopTabsParamList = {
diff --git a/native/search/message-search.react.js b/native/search/message-search.react.js
new file mode 100644
--- /dev/null
+++ b/native/search/message-search.react.js
@@ -0,0 +1,75 @@
+// @flow
+
+import invariant from 'invariant';
+import * as React from 'react';
+import { View } from 'react-native';
+
+import type { MessageInfo } from 'lib/types/message-types.js';
+import type { ThreadInfo } from 'lib/types/thread-types.js';
+
+import SearchFooter from './search-footer.react.js';
+import { MessageSearchContext } from './search-provider.react.js';
+import type { ChatNavigationProp } from '../chat/chat.react.js';
+import type { NavigationRoute } from '../navigation/route-names.js';
+import { useStyles } from '../themes/colors.js';
+
+export type MessageSearchParams = {
+ +threadInfo: ThreadInfo,
+};
+
+export type MessageSearchProps = {
+ +navigation: ChatNavigationProp<'MessageSearch'>,
+ +route: NavigationRoute<'MessageSearch'>,
+};
+
+function MessageSearch(props: MessageSearchProps): React.Node {
+ const searchContext = React.useContext(MessageSearchContext);
+ invariant(searchContext, 'searchContext should be set');
+ const { query, clearQuery } = searchContext;
+
+ React.useEffect(() => {
+ return props.navigation.addListener('beforeRemove', () => {
+ clearQuery();
+ });
+ }, [props.navigation, clearQuery]);
+
+ // eslint-disable-next-line no-unused-vars
+ const [lastID, setLastID] = React.useState();
+
+ // eslint-disable-next-line no-unused-vars
+ const [searchResults, setSearchResults] = React.useState([]);
+
+ // eslint-disable-next-line no-unused-vars
+ const appendSearchResults = React.useCallback(
+ (newMessages: $ReadOnlyArray<MessageInfo>) => {
+ setSearchResults(oldMessages => [...oldMessages, ...newMessages]);
+ },
+ [],
+ );
+
+ React.useEffect(() => {
+ setSearchResults([]);
+ setLastID(undefined);
+ }, [query]);
+
+ const styles = useStyles(unboundStyles);
+
+ if (query === '') {
+ return (
+ <View style={styles.content}>
+ <SearchFooter text="Your search results will appear here" />
+ </View>
+ );
+ }
+
+ return null;
+}
+
+const unboundStyles = {
+ content: {
+ height: '100%',
+ backgroundColor: 'panelBackground',
+ },
+};
+
+export default MessageSearch;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 7:05 PM (8 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700851
Default Alt Text
D7773.id26718.diff (4 KB)
Attached To
Mode
D7773: [native] Add message search screen
Attached
Detach File
Event Timeline
Log In to Comment