From 1e3b7feccfb59c70a97ed51b26bee8c6ea33348f Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Fri, 14 Feb 2025 23:22:32 +0000
Subject: Screen for searching user's posts (#7622)

* search user's posts screen

* custom placeholder copy if self

* navigate to /profile/:handle

* add name to title

* show header on desktop
---
 src/screens/Profile/ProfileSearch.tsx | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 src/screens/Profile/ProfileSearch.tsx

(limited to 'src/screens/Profile/ProfileSearch.tsx')

diff --git a/src/screens/Profile/ProfileSearch.tsx b/src/screens/Profile/ProfileSearch.tsx
new file mode 100644
index 000000000..d91dc973e
--- /dev/null
+++ b/src/screens/Profile/ProfileSearch.tsx
@@ -0,0 +1,42 @@
+import {useMemo} from 'react'
+import {msg} from '@lingui/macro'
+import {useLingui} from '@lingui/react'
+
+import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
+import {useProfileQuery} from '#/state/queries/profile'
+import {useResolveDidQuery} from '#/state/queries/resolve-uri'
+import {useSession} from '#/state/session'
+import {SearchScreenShell} from '#/view/screens/Search/Search'
+
+type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileSearch'>
+export const ProfileSearchScreen = ({route}: Props) => {
+  const {name, q: queryParam = ''} = route.params
+  const {_} = useLingui()
+  const {currentAccount} = useSession()
+
+  const {data: resolvedDid} = useResolveDidQuery(name)
+  const {data: profile} = useProfileQuery({did: resolvedDid})
+
+  const fixedParams = useMemo(
+    () => ({
+      from: profile?.handle ?? name,
+    }),
+    [profile?.handle, name],
+  )
+
+  return (
+    <SearchScreenShell
+      navButton="back"
+      inputPlaceholder={
+        profile
+          ? currentAccount?.did === profile.did
+            ? _(msg`Search my posts`)
+            : _(msg`Search @${profile.handle}'s posts`)
+          : _(msg`Search...`)
+      }
+      fixedParams={fixedParams}
+      queryParam={queryParam}
+      testID="searchPostsScreen"
+    />
+  )
+}
-- 
cgit 1.4.1

