From 0a7734f9ed391b05588e3740eaa53f6a58d5d657 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 21 Apr 2025 19:16:59 -0500 Subject: Refactor search history (#8260) --- src/screens/Search/Shell.tsx | 2 +- src/screens/Search/components/SearchHistory.tsx | 178 ++++++++++-------------- 2 files changed, 73 insertions(+), 107 deletions(-) (limited to 'src') diff --git a/src/screens/Search/Shell.tsx b/src/screens/Search/Shell.tsx index 20aafd623..959677784 100644 --- a/src/screens/Search/Shell.tsx +++ b/src/screens/Search/Shell.tsx @@ -112,7 +112,7 @@ export function SearchScreenShell({ const newAccountHistory = [ item.did, ...accountHistory.filter(p => p !== item.did), - ].slice(0, 5) + ].slice(0, 10) setAccountHistory(newAccountHistory) }, [accountHistory, setAccountHistory], diff --git a/src/screens/Search/components/SearchHistory.tsx b/src/screens/Search/components/SearchHistory.tsx index 048203ed8..1d7c68e13 100644 --- a/src/screens/Search/components/SearchHistory.tsx +++ b/src/screens/Search/components/SearchHistory.tsx @@ -1,4 +1,4 @@ -import {Pressable, ScrollView, StyleSheet, View} from 'react-native' +import {Pressable, ScrollView, View} from 'react-native' import {moderateProfile, type ModerationOpts} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -8,13 +8,13 @@ import {makeProfileLink} from '#/lib/routes/links' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' import {useModerationOpts} from '#/state/preferences/moderation-opts' -import {Link} from '#/view/com/util/Link' import {UserAvatar} from '#/view/com/util/UserAvatar' import {BlockDrawerGesture} from '#/view/shell/BlockDrawerGesture' -import {atoms as a, tokens, useBreakpoints, useTheme, web} from '#/alf' +import {atoms as a} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' import * as Layout from '#/components/Layout' +import {Link} from '#/components/Link' import {Text} from '#/components/Typography' import {useSimpleVerificationState} from '#/components/verification' import {VerificationCheck} from '#/components/verification/VerificationCheck' @@ -35,7 +35,6 @@ export function SearchHistory({ onRemoveItemClick: (item: string) => void onRemoveProfileClick: (profile: bsky.profile.AnyProfileView) => void }) { - const {gtMobile} = useBreakpoints() const {_} = useLingui() const moderationOpts = useModerationOpts() @@ -43,54 +42,52 @@ export function SearchHistory({ - + {(searchHistory.length > 0 || selectedProfiles.length > 0) && ( - - Recent Searches - + + + Recent Searches + + )} + {selectedProfiles.length > 0 && ( - + + a.gap_xl, + ]}> {moderationOpts && - selectedProfiles - .slice(0, 5) - .map(profile => ( - onProfileClick(profile)} - onRemove={() => onRemoveProfileClick(profile)} - /> - ))} + selectedProfiles.map(profile => ( + onProfileClick(profile)} + onRemove={() => onRemoveProfileClick(profile)} + /> + ))} )} + {searchHistory.length > 0 && ( - + {searchHistory.slice(0, 5).map((historyItem, index) => ( - + onItemClick(historyItem)} hitSlop={HITSLOP_10} - style={[a.flex_1, a.py_md]}> + style={[a.flex_1, a.py_sm]}> {historyItem} ) } - -const styles = StyleSheet.create({ - selectedProfilesContainer: { - marginTop: 10, - paddingHorizontal: 12, - height: 80, - }, - selectedProfilesContainerMobile: { - height: 100, - }, - profileItem: { - alignItems: 'center', - marginRight: 15, - width: 78, - }, - profileItemMobile: { - width: 70, - }, - profileName: { - width: 78, - marginTop: 6, - }, - profileRemoveBtn: { - position: 'absolute', - top: 0, - right: 5, - backgroundColor: 'white', - borderRadius: 10, - width: 18, - height: 18, - alignItems: 'center', - justifyContent: 'center', - }, -}) -- cgit 1.4.1