Add fulltext search for posts and profiles (closes #340) (#342)

* Refactor mobile search screen

* Remove 'staleness' fetch trigger on search

* Implement a temporary fulltext search solution

* Add missing key from profile search result

* A few UI & UX improvements to the search suggestions

* Update web search suggestions

* Implement search in web build
This commit is contained in:
Paul Frazee 2023-03-21 17:58:50 -05:00 committed by GitHub
parent 48e18662f6
commit a7e3ce2585
16 changed files with 587 additions and 283 deletions

View file

@ -0,0 +1,50 @@
import React from 'react'
import {StyleSheet, View} from 'react-native'
import {observer} from 'mobx-react-lite'
import {FoafsModel} from 'state/models/discovery/foafs'
import {WhoToFollow} from 'view/com/discover/WhoToFollow'
import {SuggestedFollows} from 'view/com/discover/SuggestedFollows'
import {ProfileCardFeedLoadingPlaceholder} from 'view/com/util/LoadingPlaceholder'
export const Suggestions = observer(({foafs}: {foafs: FoafsModel}) => {
if (foafs.isLoading) {
return <ProfileCardFeedLoadingPlaceholder />
}
if (foafs.hasContent) {
return (
<>
{foafs.popular.length > 0 && (
<View style={styles.suggestions}>
<SuggestedFollows
title="In your network"
suggestions={foafs.popular}
/>
</View>
)}
<WhoToFollow />
{foafs.sources.map((source, i) => {
const item = foafs.foafs.get(source)
if (!item || item.follows.length === 0) {
return <View key={`sf-${item?.did || i}`} />
}
return (
<View key={`sf-${item.did}`} style={styles.suggestions}>
<SuggestedFollows
title={`Followed by ${item.displayName || item.handle}`}
suggestions={item.follows.slice(0, 10)}
/>
</View>
)
})}
</>
)
}
return <WhoToFollow />
})
const styles = StyleSheet.create({
suggestions: {
marginTop: 10,
marginBottom: 20,
},
})