reload AlgoItem on focus via prop

zio/stable
Ansh Nanda 2023-05-16 16:27:38 -07:00
parent 3f41d3db26
commit 1e54125f7f
2 changed files with 6 additions and 1 deletions

View File

@ -24,11 +24,13 @@ const AlgoItem = observer(
style, style,
showBottom = true, showBottom = true,
onLongPress, onLongPress,
reloadOnFocus = false,
}: { }: {
item: AlgoItemModel item: AlgoItemModel
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
showBottom?: boolean showBottom?: boolean
onLongPress?: () => void onLongPress?: () => void
reloadOnFocus?: boolean
}) => { }) => {
const store = useStores() const store = useStores()
const pal = usePalette('default') const pal = usePalette('default')
@ -36,7 +38,9 @@ const AlgoItem = observer(
// TODO: this is pretty hacky, but it works for now // TODO: this is pretty hacky, but it works for now
useFocusEffect(() => { useFocusEffect(() => {
item.reload() if (reloadOnFocus) {
item.reload()
}
}) })
return ( return (

View File

@ -174,6 +174,7 @@ export function PostEmbeds({
<AlgoItem <AlgoItem
item={new AlgoItemModel(store, embed.record)} item={new AlgoItemModel(store, embed.record)}
style={[pal.view, pal.border, styles.extOuter]} style={[pal.view, pal.border, styles.extOuter]}
reloadOnFocus={true}
/> />
) )
} }