From 1fda26103212461fae6092f426b99cd21f7f319a Mon Sep 17 00:00:00 2001 From: Mary Kate Fain Date: Wed, 22 May 2024 10:52:56 -0500 Subject: [PATCH 1/5] change Search to Discover --- src/__fixtures__/intlMessages.json | 8 ++++---- src/actions/search.ts | 2 +- src/components/sidebar-navigation.tsx | 2 +- src/features/aliases/components/search.tsx | 2 +- src/features/groups/discover.tsx | 2 +- src/features/list-editor/components/search.tsx | 2 +- src/features/search/index.tsx | 2 +- src/locales/en.json | 6 +++--- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/__fixtures__/intlMessages.json b/src/__fixtures__/intlMessages.json index 30ce6f35c..69c396722 100644 --- a/src/__fixtures__/intlMessages.json +++ b/src/__fixtures__/intlMessages.json @@ -373,7 +373,7 @@ "report.placeholder": "Additional comments", "report.submit": "Submit", "report.target": "Reporting {target}", - "search.placeholder": "Search", + "search.placeholder": "Discover", "search_popout.search_format": "Advanced search format", "search_popout.tips.full_text": "Simple text returns posts you have written, favorited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", @@ -448,7 +448,7 @@ "tabs_bar.news": "News", "tabs_bar.notifications": "Alerts", "tabs_bar.post": "Post", - "tabs_bar.search": "Search", + "tabs_bar.search": "Discover", "time_remaining.days": "{number, plural, one {# day} other {# days}} left", "time_remaining.hours": "{number, plural, one {# hour} other {# hours}} left", "time_remaining.minutes": "{number, plural, one {# minute} other {# minutes}} left", @@ -854,7 +854,7 @@ "report.placeholder": "Additional comments", "report.submit": "Submit", "report.target": "Reporting {target}", - "search.placeholder": "Search", + "search.placeholder": "Discover", "search_popout.search_format": "Advanced search format", "search_popout.tips.full_text": "Simple text returns posts you have written, favorited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", @@ -929,7 +929,7 @@ "tabs_bar.news": "News", "tabs_bar.notifications": "Alerts", "tabs_bar.post": "Post", - "tabs_bar.search": "Search", + "tabs_bar.search": "Discover", "time_remaining.days": "{number, plural, one {# day} other {# days}} left", "time_remaining.hours": "{number, plural, one {# hour} other {# hours}} left", "time_remaining.minutes": "{number, plural, one {# minute} other {# minutes}} left", diff --git a/src/actions/search.ts b/src/actions/search.ts index 7031173c4..8810605eb 100644 --- a/src/actions/search.ts +++ b/src/actions/search.ts @@ -52,7 +52,7 @@ const clearSearchResults = () => ({ const submitSearch = (filter?: SearchFilter) => (dispatch: AppDispatch, getState: () => RootState) => { const value = getState().search.value; - const type = filter || getState().search.filter || 'accounts'; + const type = filter || getState().search.filter || 'statuses'; const accountId = getState().search.accountId; // An empty search doesn't return any results diff --git a/src/components/sidebar-navigation.tsx b/src/components/sidebar-navigation.tsx index 3c68ee892..e46aa38c5 100644 --- a/src/components/sidebar-navigation.tsx +++ b/src/components/sidebar-navigation.tsx @@ -125,7 +125,7 @@ const SidebarNavigation = () => { } + text={} /> {account && ( diff --git a/src/features/aliases/components/search.tsx b/src/features/aliases/components/search.tsx index 5b654a777..a859a93a6 100644 --- a/src/features/aliases/components/search.tsx +++ b/src/features/aliases/components/search.tsx @@ -9,7 +9,7 @@ import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; const messages = defineMessages({ search: { id: 'aliases.search', defaultMessage: 'Search your old account' }, - searchTitle: { id: 'tabs_bar.search', defaultMessage: 'Search' }, + searchTitle: { id: 'tabs_bar.search', defaultMessage: 'Discover' }, }); const Search: React.FC = () => { diff --git a/src/features/groups/discover.tsx b/src/features/groups/discover.tsx index 0bb5af179..ef8fd4de4 100644 --- a/src/features/groups/discover.tsx +++ b/src/features/groups/discover.tsx @@ -10,7 +10,7 @@ import SuggestedGroups from './components/discover/suggested-groups'; import TabBar, { TabItems } from './components/tab-bar'; const messages = defineMessages({ - placeholder: { id: 'groups.discover.search.placeholder', defaultMessage: 'Search' }, + placeholder: { id: 'groups.discover.search.placeholder', defaultMessage: 'Discover' }, }); const Discover: React.FC = () => { diff --git a/src/features/list-editor/components/search.tsx b/src/features/list-editor/components/search.tsx index e3c3812c7..71f136247 100644 --- a/src/features/list-editor/components/search.tsx +++ b/src/features/list-editor/components/search.tsx @@ -9,7 +9,7 @@ import { useAppSelector, useAppDispatch } from 'soapbox/hooks'; const messages = defineMessages({ search: { id: 'lists.search', defaultMessage: 'Search among people you follow' }, - searchTitle: { id: 'tabs_bar.search', defaultMessage: 'Search' }, + searchTitle: { id: 'tabs_bar.search', defaultMessage: 'Discover' }, }); const Search = () => { diff --git a/src/features/search/index.tsx b/src/features/search/index.tsx index a61700b2b..beee52773 100644 --- a/src/features/search/index.tsx +++ b/src/features/search/index.tsx @@ -6,7 +6,7 @@ import Search from 'soapbox/features/compose/components/search'; import SearchResults from 'soapbox/features/compose/components/search-results'; const messages = defineMessages({ - heading: { id: 'column.search', defaultMessage: 'Search' }, + heading: { id: 'column.search', defaultMessage: 'Discover' }, }); const SearchPage = () => { diff --git a/src/locales/en.json b/src/locales/en.json index 2a5cad6ce..c6f52b087 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -431,7 +431,7 @@ "column.reblogs": "Reposts", "column.registration": "Sign Up", "column.scheduled_statuses": "Scheduled Posts", - "column.search": "Search", + "column.search": "Discover", "column.settings_store": "Settings store", "column.soapbox_config": "Soapbox config", "column.test": "Test timeline", @@ -901,7 +901,7 @@ "groups.discover.search.error.title": "An error occurred", "groups.discover.search.no_results.subtitle": "Try searching for another group.", "groups.discover.search.no_results.title": "No matches found", - "groups.discover.search.placeholder": "Search", + "groups.discover.search.placeholder": "Discover", "groups.discover.search.recent_searches.blankslate.subtitle": "Search group names, topics or keywords", "groups.discover.search.recent_searches.blankslate.title": "No recent searches", "groups.discover.search.recent_searches.clear_all": "Clear all", @@ -1577,7 +1577,7 @@ "tabs_bar.more": "More", "tabs_bar.notifications": "Notifications", "tabs_bar.profile": "Profile", - "tabs_bar.search": "Search", + "tabs_bar.search": "Discover", "tabs_bar.settings": "Settings", "textarea.counter.label": "{count} characters remaining", "theme_editor.colors.accent": "Accent", From 6ca49e8322c3c968262d4a2e7dabab12993758f9 Mon Sep 17 00:00:00 2001 From: Mary Kate Fain Date: Wed, 22 May 2024 11:50:02 -0500 Subject: [PATCH 2/5] reorder tabs --- .../compose/components/search-results.tsx | 20 +++++++++++-------- src/reducers/search.ts | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/features/compose/components/search-results.tsx b/src/features/compose/components/search-results.tsx index 362e4abe7..f2dbcd31e 100644 --- a/src/features/compose/components/search-results.tsx +++ b/src/features/compose/components/search-results.tsx @@ -38,7 +38,7 @@ const SearchResults = () => { const trendingStatuses = useAppSelector((state) => state.trending_statuses.items); const trends = useAppSelector((state) => state.trends.items); const submitted = useAppSelector((state) => state.search.submitted); - const selectedFilter = useAppSelector((state) => state.search.filter); + const selectedFilter = useAppSelector((state) => state.search.filter || 'statuses'); const filterByAccount = useAppSelector((state) => state.search.accountId || undefined); const { account } = useAccount(filterByAccount); @@ -51,18 +51,18 @@ const SearchResults = () => { const renderFilterBar = () => { const items = []; items.push( - { - text: intl.formatMessage(messages.accounts), - action: () => selectFilter('accounts'), - name: 'accounts', - }, { text: intl.formatMessage(messages.statuses), action: () => selectFilter('statuses'), name: 'statuses', }, + { + text: intl.formatMessage(messages.accounts), + action: () => selectFilter('accounts'), + name: 'accounts', + }, ); - + items.push( { text: intl.formatMessage(messages.hashtags), @@ -70,7 +70,7 @@ const SearchResults = () => { name: 'hashtags', }, ); - + return ; }; @@ -105,6 +105,10 @@ const SearchResults = () => { useEffect(() => { dispatch(fetchTrendingStatuses()); + // Ensure the filter is set to 'statuses' initially + if (!selectedFilter) { + dispatch(setFilter('statuses')); + } }, []); let searchResults; diff --git a/src/reducers/search.ts b/src/reducers/search.ts index f4e299290..3019b2b86 100644 --- a/src/reducers/search.ts +++ b/src/reducers/search.ts @@ -45,14 +45,14 @@ const ReducerRecord = ImmutableRecord({ submittedValue: '', hidden: false, results: ResultsRecord(), - filter: 'accounts' as SearchFilter, + filter: 'statuses' as SearchFilter, accountId: null as string | null, next: null as string | null, }); type State = ReturnType; type APIEntities = Array; -export type SearchFilter = 'accounts' | 'statuses' | 'groups' | 'hashtags'; +export type SearchFilter = 'statuses' | 'accounts' | 'groups' | 'hashtags'; const toIds = (items: APIEntities = []) => { return ImmutableOrderedSet(items.map(item => item.id)); @@ -62,8 +62,8 @@ const importResults = (state: State, results: APIEntity, searchTerm: string, sea return state.withMutations(state => { if (state.value === searchTerm && state.filter === searchType) { state.set('results', ResultsRecord({ - accounts: toIds(results.accounts), statuses: toIds(results.statuses), + accounts: toIds(results.accounts), groups: toIds(results.groups), hashtags: ImmutableOrderedSet(results.hashtags.map(normalizeTag)), // it's a list of records accountsHasMore: results.accounts.length >= 20, From a2a73dedbce16ae923525247d1ac9111d19d1a93 Mon Sep 17 00:00:00 2001 From: Mary Kate Fain Date: Wed, 22 May 2024 11:52:24 -0500 Subject: [PATCH 3/5] reset to statuses --- src/reducers/search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reducers/search.ts b/src/reducers/search.ts index 3019b2b86..06869cd89 100644 --- a/src/reducers/search.ts +++ b/src/reducers/search.ts @@ -144,7 +144,7 @@ export default function search(state = ReducerRecord(), action: AnyAction) { results: ResultsRecord(), submitted: false, submittedValue: '', - filter: 'accounts', + filter: 'statuses', accountId: null, }); return ReducerRecord({ accountId: action.accountId, filter: 'statuses' }); From 9444b1a64742f2730b767098bb42090ef2904619 Mon Sep 17 00:00:00 2001 From: Mary Kate Fain Date: Wed, 22 May 2024 13:14:18 -0500 Subject: [PATCH 4/5] but Search back on placeholder text --- src/__fixtures__/intlMessages.json | 4 ++-- src/features/groups/discover.tsx | 2 +- src/locales/en.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/__fixtures__/intlMessages.json b/src/__fixtures__/intlMessages.json index 69c396722..4b8a45bdf 100644 --- a/src/__fixtures__/intlMessages.json +++ b/src/__fixtures__/intlMessages.json @@ -373,7 +373,7 @@ "report.placeholder": "Additional comments", "report.submit": "Submit", "report.target": "Reporting {target}", - "search.placeholder": "Discover", + "search.placeholder": "Search", "search_popout.search_format": "Advanced search format", "search_popout.tips.full_text": "Simple text returns posts you have written, favorited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", @@ -854,7 +854,7 @@ "report.placeholder": "Additional comments", "report.submit": "Submit", "report.target": "Reporting {target}", - "search.placeholder": "Discover", + "search.placeholder": "Search", "search_popout.search_format": "Advanced search format", "search_popout.tips.full_text": "Simple text returns posts you have written, favorited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", diff --git a/src/features/groups/discover.tsx b/src/features/groups/discover.tsx index ef8fd4de4..0bb5af179 100644 --- a/src/features/groups/discover.tsx +++ b/src/features/groups/discover.tsx @@ -10,7 +10,7 @@ import SuggestedGroups from './components/discover/suggested-groups'; import TabBar, { TabItems } from './components/tab-bar'; const messages = defineMessages({ - placeholder: { id: 'groups.discover.search.placeholder', defaultMessage: 'Discover' }, + placeholder: { id: 'groups.discover.search.placeholder', defaultMessage: 'Search' }, }); const Discover: React.FC = () => { diff --git a/src/locales/en.json b/src/locales/en.json index c6f52b087..2102aa113 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -901,7 +901,7 @@ "groups.discover.search.error.title": "An error occurred", "groups.discover.search.no_results.subtitle": "Try searching for another group.", "groups.discover.search.no_results.title": "No matches found", - "groups.discover.search.placeholder": "Discover", + "groups.discover.search.placeholder": "Search", "groups.discover.search.recent_searches.blankslate.subtitle": "Search group names, topics or keywords", "groups.discover.search.recent_searches.blankslate.title": "No recent searches", "groups.discover.search.recent_searches.clear_all": "Clear all", From 73704361924ecc8ee7c6cfecdcbf7ad8c96485f5 Mon Sep 17 00:00:00 2001 From: Mary Kate Fain Date: Wed, 22 May 2024 13:18:18 -0500 Subject: [PATCH 5/5] remove unndeed setting statuses default --- src/features/compose/components/search-results.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/features/compose/components/search-results.tsx b/src/features/compose/components/search-results.tsx index f2dbcd31e..c2beaf547 100644 --- a/src/features/compose/components/search-results.tsx +++ b/src/features/compose/components/search-results.tsx @@ -38,7 +38,7 @@ const SearchResults = () => { const trendingStatuses = useAppSelector((state) => state.trending_statuses.items); const trends = useAppSelector((state) => state.trends.items); const submitted = useAppSelector((state) => state.search.submitted); - const selectedFilter = useAppSelector((state) => state.search.filter || 'statuses'); + const selectedFilter = useAppSelector((state) => state.search.filter); const filterByAccount = useAppSelector((state) => state.search.accountId || undefined); const { account } = useAccount(filterByAccount); @@ -105,10 +105,6 @@ const SearchResults = () => { useEffect(() => { dispatch(fetchTrendingStatuses()); - // Ensure the filter is set to 'statuses' initially - if (!selectedFilter) { - dispatch(setFilter('statuses')); - } }, []); let searchResults;