diff --git a/src/action-sheets/index.js b/src/action-sheets/index.js index 8f75ba558ca..810e474e14b 100644 --- a/src/action-sheets/index.js +++ b/src/action-sheets/index.js @@ -31,7 +31,13 @@ import type { PmKeyRecipients } from '../utils/recipient'; import { isTopicMuted } from '../mute/muteModel'; import * as api from '../api'; import { showToast } from '../utils/info'; -import { doNarrow, deleteOutboxMessage, navigateToEmojiPicker, navigateToStream } from '../actions'; +import { + doNarrow, + deleteOutboxMessage, + navigateToEmojiPicker, + navigateToStream, + navigateToSearch, +} from '../actions'; import { navigateToMessageReactionScreen, navigateToPmConversationDetails, @@ -236,6 +242,12 @@ const unsubscribe = async ({ auth, streamId, subscriptions }) => { unsubscribe.title = 'Unsubscribe'; unsubscribe.errorMessage = 'Failed to unsubscribe'; +const searchMessage = ({ streamId }) => { + NavigationService.dispatch(navigateToSearch(streamId)); +}; +searchMessage.title = 'Search Message'; +searchMessage.errorMessage = 'Failed to open search'; + const pinToTop = async ({ auth, streamId }) => { await api.setSubscriptionProperty(auth, streamId, 'pin_to_top', true); }; @@ -339,6 +351,7 @@ export const constructStreamActionButtons = ({ buttons.push(subscribe); } buttons.push(showStreamSettings); + buttons.push(searchMessage); buttons.push(cancel); return buttons; }; diff --git a/src/nav/navActions.js b/src/nav/navActions.js index 05db356fe04..e8c273a719a 100644 --- a/src/nav/navActions.js +++ b/src/nav/navActions.js @@ -49,7 +49,8 @@ export const replaceWithChat = (narrow: Narrow): GenericNavigationAction => export const navigateToUsersScreen = (): GenericNavigationAction => StackActions.push('users'); -export const navigateToSearch = (): GenericNavigationAction => StackActions.push('search-messages'); +export const navigateToSearch = (streamId?: number): GenericNavigationAction => + StackActions.push('search-messages', { streamId }); export const navigateToEmojiPicker = (messageId: number): GenericNavigationAction => StackActions.push('emoji-picker', { messageId }); diff --git a/src/search/SearchMessagesScreen.js b/src/search/SearchMessagesScreen.js index 5177d330ea8..bd643902807 100644 --- a/src/search/SearchMessagesScreen.js +++ b/src/search/SearchMessagesScreen.js @@ -18,7 +18,7 @@ import { fetchMessages } from '../message/fetchActions'; type OuterProps = $ReadOnly<{| // These should be passed from React Navigation navigation: AppNavigationProp<'search-messages'>, - route: RouteProp<'search-messages', void>, + route: RouteProp<'search-messages', {| streamId: number |}>, |}>; type SelectorProps = $ReadOnly<{| @@ -65,7 +65,7 @@ class SearchMessagesScreenInner extends PureComponent { */ fetchSearchMessages = async (query: string): Promise<$ReadOnlyArray> => { const fetchArgs = { - narrow: SEARCH_NARROW(query), + narrow: SEARCH_NARROW(query, this.props.route.params.streamId), anchor: LAST_MESSAGE_ANCHOR, numBefore: 20, numAfter: 0, @@ -144,7 +144,7 @@ class SearchMessagesScreenInner extends PureComponent { ); diff --git a/static/translations/messages_en.json b/static/translations/messages_en.json index 8da299864f9..6925ea5b591 100644 --- a/static/translations/messages_en.json +++ b/static/translations/messages_en.json @@ -213,6 +213,8 @@ "Failed to delete topic": "Failed to delete topic", "Stream settings": "Stream settings", "Failed to show stream settings": "Failed to show stream settings", + "Search Message": "Search Message", + "Failed to open search": "Failed to open search", "show": "show", "hide": "hide", "Debug": "Debug",