Skip to content

Commit

Permalink
Search in PWI (#3628)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Apr 19, 2024
1 parent d3c0b48 commit ce1c1e1
Showing 1 changed file with 52 additions and 92 deletions.
144 changes: 52 additions & 92 deletions src/view/screens/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,7 @@ function SearchScreenUserResults({
)
}

export function SearchScreenInner({
query,
primarySearch,
}: {
query?: string
primarySearch?: boolean
}) {
export function SearchScreenInner({query}: {query?: string}) {
const pal = usePalette('default')
const setMinimalShellMode = useSetMinimalShellMode()
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
Expand All @@ -419,86 +413,35 @@ export function SearchScreenInner({

const sections = React.useMemo(() => {
if (!query) return []
if (hasSession) {
return [
{
title: _(msg`Top`),
component: (
<SearchScreenPostResults
query={query}
sort="top"
active={activeTab === 0}
/>
),
},
{
title: _(msg`Latest`),
component: (
<SearchScreenPostResults
query={query}
sort="latest"
active={activeTab === 1}
/>
),
},
{
title: _(msg`People`),
component: (
<SearchScreenUserResults query={query} active={activeTab === 2} />
),
},
]
} else {
return [
{
title: _(msg`People`),
component: (
<SearchScreenUserResults query={query} active={activeTab === 0} />
),
},
]
}
}, [hasSession, _, query, activeTab])

if (hasSession) {
return query ? (
<Pager
onPageSelected={onPageSelected}
renderTabBar={props => (
<CenteredView
sideBorders
style={[pal.border, pal.view, styles.tabBarContainer]}>
<TabBar items={sections.map(section => section.title)} {...props} />
</CenteredView>
)}
initialPage={0}>
{sections.map((section, i) => (
<View key={i}>{section.component}</View>
))}
</Pager>
) : (
<View>
<CenteredView sideBorders style={pal.border}>
<Text
type="title"
style={[
pal.text,
pal.border,
{
display: 'flex',
paddingVertical: 12,
paddingHorizontal: 18,
fontWeight: 'bold',
},
]}>
<Trans>Suggested Follows</Trans>
</Text>
</CenteredView>

<SearchScreenSuggestedFollows />
</View>
)
}
return [
{
title: _(msg`Top`),
component: (
<SearchScreenPostResults
query={query}
sort="top"
active={activeTab === 0}
/>
),
},
{
title: _(msg`Latest`),
component: (
<SearchScreenPostResults
query={query}
sort="latest"
active={activeTab === 1}
/>
),
},
{
title: _(msg`People`),
component: (
<SearchScreenUserResults query={query} active={activeTab === 2} />
),
},
]
}, [_, query, activeTab])

return query ? (
<Pager
Expand All @@ -515,6 +458,27 @@ export function SearchScreenInner({
<View key={i}>{section.component}</View>
))}
</Pager>
) : hasSession ? (
<View>
<CenteredView sideBorders style={pal.border}>
<Text
type="title"
style={[
pal.text,
pal.border,
{
display: 'flex',
paddingVertical: 12,
paddingHorizontal: 18,
fontWeight: 'bold',
},
]}>
<Trans>Suggested Follows</Trans>
</Text>
</CenteredView>

<SearchScreenSuggestedFollows />
</View>
) : (
<CenteredView sideBorders style={pal.border}>
<View
Expand Down Expand Up @@ -554,11 +518,7 @@ export function SearchScreenInner({
style={pal.textLight}
/>
<Text type="xl" style={[pal.textLight, {paddingHorizontal: 18}]}>
{isDesktop && !primarySearch ? (
<Trans>Find users with the search tool on the right</Trans>
) : (
<Trans>Find users on Bluesky</Trans>
)}
<Trans>Find posts and users on Bluesky</Trans>
</Text>
</View>
</View>
Expand Down

0 comments on commit ce1c1e1

Please sign in to comment.