Revise FeedSourceCard load state to allow deletion for failures (#2172)

* Revise FeedSourceCard load state to allow deletion for failures

* Translate

* Remove test error feed

* Fix missing uri param

---------

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
zio/stable
Eric Bailey 2023-12-11 16:48:22 -06:00 committed by GitHub
parent 586c2417a8
commit 9a59525b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 107 additions and 41 deletions

View File

@ -744,7 +744,7 @@ msgid "Edit list details"
msgstr "" msgstr ""
#: src/view/screens/Feeds.tsx:367 #: src/view/screens/Feeds.tsx:367
#: src/view/screens/SavedFeeds.tsx:85 #: src/view/screens/SavedFeeds.tsx:84
msgid "Edit My Feeds" msgid "Edit My Feeds"
msgstr "" msgstr ""
@ -858,7 +858,7 @@ msgstr ""
msgid "Feeds are created by users to curate content. Choose some feeds that you find interesting." msgid "Feeds are created by users to curate content. Choose some feeds that you find interesting."
msgstr "" msgstr ""
#: src/view/screens/SavedFeeds.tsx:156 #: src/view/screens/SavedFeeds.tsx:164
msgid "Feeds are custom algorithms that users build with a little coding expertise. <0/> for more information." msgid "Feeds are custom algorithms that users build with a little coding expertise. <0/> for more information."
msgstr "" msgstr ""
@ -1536,7 +1536,7 @@ msgstr ""
msgid "Pictures meant for adults." msgid "Pictures meant for adults."
msgstr "" msgstr ""
#: src/view/screens/SavedFeeds.tsx:89 #: src/view/screens/SavedFeeds.tsx:88
msgid "Pinned Feeds" msgid "Pinned Feeds"
msgstr "" msgstr ""
@ -1676,7 +1676,7 @@ msgstr ""
msgid "Remove" msgid "Remove"
msgstr "" msgstr ""
#: src/view/com/feeds/FeedSourceCard.tsx:108 #: src/view/com/feeds/FeedSourceCard.tsx:106
msgid "Remove {0} from my feeds?" msgid "Remove {0} from my feeds?"
msgstr "" msgstr ""
@ -1688,7 +1688,8 @@ msgstr ""
msgid "Remove feed" msgid "Remove feed"
msgstr "" msgstr ""
#: src/view/com/feeds/FeedSourceCard.tsx:107 #: src/view/com/feeds/FeedSourceCard.tsx:105
#: src/view/com/feeds/FeedSourceCard.tsx:172
#: src/view/screens/ProfileFeed.tsx:280 #: src/view/screens/ProfileFeed.tsx:280
msgid "Remove from my feeds" msgid "Remove from my feeds"
msgstr "" msgstr ""
@ -1701,6 +1702,10 @@ msgstr ""
msgid "Remove image preview" msgid "Remove image preview"
msgstr "" msgstr ""
#: src/view/com/feeds/FeedSourceCard.tsx:173
msgid "Remove this feed from my feeds?"
msgstr ""
#: src/view/com/posts/FeedErrorMessage.tsx:131 #: src/view/com/posts/FeedErrorMessage.tsx:131
msgid "Remove this feed from your saved feeds?" msgid "Remove this feed from your saved feeds?"
msgstr "" msgstr ""
@ -1840,7 +1845,7 @@ msgstr ""
msgid "Save image crop" msgid "Save image crop"
msgstr "" msgstr ""
#: src/view/screens/SavedFeeds.tsx:122 #: src/view/screens/SavedFeeds.tsx:130
msgid "Saved Feeds" msgid "Saved Feeds"
msgstr "" msgstr ""
@ -2427,7 +2432,7 @@ msgstr ""
msgid "You don't have any invite codes yet! We'll send you some when you've been on Bluesky for a little longer." msgid "You don't have any invite codes yet! We'll send you some when you've been on Bluesky for a little longer."
msgstr "" msgstr ""
#: src/view/screens/SavedFeeds.tsx:102 #: src/view/screens/SavedFeeds.tsx:110
msgid "You don't have any pinned feeds." msgid "You don't have any pinned feeds."
msgstr "" msgstr ""
@ -2435,7 +2440,7 @@ msgstr ""
msgid "You don't have any saved feeds!" msgid "You don't have any saved feeds!"
msgstr "" msgstr ""
#: src/view/screens/SavedFeeds.tsx:135 #: src/view/screens/SavedFeeds.tsx:143
msgid "You don't have any saved feeds." msgid "You don't have any saved feeds."
msgstr "" msgstr ""

View File

@ -740,7 +740,7 @@ msgid "Edit list details"
msgstr "सूची विवरण संपादित करें" msgstr "सूची विवरण संपादित करें"
#: src/view/screens/Feeds.tsx:367 #: src/view/screens/Feeds.tsx:367
#: src/view/screens/SavedFeeds.tsx:85 #: src/view/screens/SavedFeeds.tsx:84
msgid "Edit My Feeds" msgid "Edit My Feeds"
msgstr "मेरी फ़ीड संपादित करें" msgstr "मेरी फ़ीड संपादित करें"
@ -854,7 +854,7 @@ msgstr "सभी फ़ीड"
msgid "Feeds are created by users to curate content. Choose some feeds that you find interesting." msgid "Feeds are created by users to curate content. Choose some feeds that you find interesting."
msgstr "सामग्री को व्यवस्थित करने के लिए उपयोगकर्ताओं द्वारा फ़ीड बनाए जाते हैं। कुछ फ़ीड चुनें जो आपको दिलचस्प लगें।" msgstr "सामग्री को व्यवस्थित करने के लिए उपयोगकर्ताओं द्वारा फ़ीड बनाए जाते हैं। कुछ फ़ीड चुनें जो आपको दिलचस्प लगें।"
#: src/view/screens/SavedFeeds.tsx:156 #: src/view/screens/SavedFeeds.tsx:164
msgid "Feeds are custom algorithms that users build with a little coding expertise. <0/> for more information." msgid "Feeds are custom algorithms that users build with a little coding expertise. <0/> for more information."
msgstr "फ़ीड कस्टम एल्गोरिदम हैं जिन्हें उपयोगकर्ता थोड़ी कोडिंग विशेषज्ञता के साथ बनाते हैं। <0/> अधिक जानकारी के लिए." msgstr "फ़ीड कस्टम एल्गोरिदम हैं जिन्हें उपयोगकर्ता थोड़ी कोडिंग विशेषज्ञता के साथ बनाते हैं। <0/> अधिक जानकारी के लिए."
@ -1528,7 +1528,7 @@ msgstr "पासवर्ड अद्यतन!"
msgid "Pictures meant for adults." msgid "Pictures meant for adults."
msgstr "चित्र वयस्कों के लिए थे।।" msgstr "चित्र वयस्कों के लिए थे।।"
#: src/view/screens/SavedFeeds.tsx:89 #: src/view/screens/SavedFeeds.tsx:88
msgid "Pinned Feeds" msgid "Pinned Feeds"
msgstr "पिन किया गया फ़ीड" msgstr "पिन किया गया फ़ीड"
@ -1668,7 +1668,7 @@ msgstr "अनुशंसित लोग"
msgid "Remove" msgid "Remove"
msgstr "निकालें" msgstr "निकालें"
#: src/view/com/feeds/FeedSourceCard.tsx:108 #: src/view/com/feeds/FeedSourceCard.tsx:106
msgid "Remove {0} from my feeds?" msgid "Remove {0} from my feeds?"
msgstr "मेरे फ़ीड से {0} हटाएं?" msgstr "मेरे फ़ीड से {0} हटाएं?"
@ -1680,7 +1680,8 @@ msgstr "खाता हटाएं"
msgid "Remove feed" msgid "Remove feed"
msgstr "फ़ीड हटाएँ" msgstr "फ़ीड हटाएँ"
#: src/view/com/feeds/FeedSourceCard.tsx:107 #: src/view/com/feeds/FeedSourceCard.tsx:105
#: src/view/com/feeds/FeedSourceCard.tsx:172
#: src/view/screens/ProfileFeed.tsx:280 #: src/view/screens/ProfileFeed.tsx:280
msgid "Remove from my feeds" msgid "Remove from my feeds"
msgstr "मेरे फ़ीड से हटाएँ" msgstr "मेरे फ़ीड से हटाएँ"
@ -1693,6 +1694,10 @@ msgstr "छवि निकालें"
msgid "Remove image preview" msgid "Remove image preview"
msgstr "छवि पूर्वावलोकन निकालें" msgstr "छवि पूर्वावलोकन निकालें"
#: src/view/com/feeds/FeedSourceCard.tsx:173
msgid "Remove this feed from my feeds?"
msgstr ""
#: src/view/com/posts/FeedErrorMessage.tsx:131 #: src/view/com/posts/FeedErrorMessage.tsx:131
msgid "Remove this feed from your saved feeds?" msgid "Remove this feed from your saved feeds?"
msgstr "इस फ़ीड को सहेजे गए फ़ीड से हटा दें?" msgstr "इस फ़ीड को सहेजे गए फ़ीड से हटा दें?"
@ -1832,7 +1837,7 @@ msgstr "बदलाव सेव करो"
msgid "Save image crop" msgid "Save image crop"
msgstr "फोटो बदलाव सेव करो" msgstr "फोटो बदलाव सेव करो"
#: src/view/screens/SavedFeeds.tsx:122 #: src/view/screens/SavedFeeds.tsx:130
msgid "Saved Feeds" msgid "Saved Feeds"
msgstr "सहेजे गए फ़ीड" msgstr "सहेजे गए फ़ीड"
@ -2419,7 +2424,7 @@ msgstr "अब आप अपने नए पासवर्ड के साथ
msgid "You don't have any invite codes yet! We'll send you some when you've been on Bluesky for a little longer." msgid "You don't have any invite codes yet! We'll send you some when you've been on Bluesky for a little longer."
msgstr "आपके पास अभी तक कोई आमंत्रण कोड नहीं है! जब आप कुछ अधिक समय के लिए Bluesky पर रहेंगे तो हम आपको कुछ भेजेंगे।" msgstr "आपके पास अभी तक कोई आमंत्रण कोड नहीं है! जब आप कुछ अधिक समय के लिए Bluesky पर रहेंगे तो हम आपको कुछ भेजेंगे।"
#: src/view/screens/SavedFeeds.tsx:102 #: src/view/screens/SavedFeeds.tsx:110
msgid "You don't have any pinned feeds." msgid "You don't have any pinned feeds."
msgstr "आपके पास कोई पिन किया हुआ फ़ीड नहीं है." msgstr "आपके पास कोई पिन किया हुआ फ़ीड नहीं है."
@ -2427,7 +2432,7 @@ msgstr "आपके पास कोई पिन किया हुआ फ़
msgid "You don't have any saved feeds!" msgid "You don't have any saved feeds!"
msgstr "" msgstr ""
#: src/view/screens/SavedFeeds.tsx:135 #: src/view/screens/SavedFeeds.tsx:143
msgid "You don't have any saved feeds." msgid "You don't have any saved feeds."
msgstr "आपके पास कोई सहेजी गई फ़ीड नहीं है." msgstr "आपके पास कोई सहेजी गई फ़ीड नहीं है."

View File

@ -32,30 +32,23 @@ export function FeedSourceCard({
showSaveBtn = false, showSaveBtn = false,
showDescription = false, showDescription = false,
showLikes = false, showLikes = false,
LoadingComponent,
pinOnSave = false, pinOnSave = false,
showMinimalPlaceholder,
}: { }: {
feedUri: string feedUri: string
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
showSaveBtn?: boolean showSaveBtn?: boolean
showDescription?: boolean showDescription?: boolean
showLikes?: boolean showLikes?: boolean
LoadingComponent?: JSX.Element
pinOnSave?: boolean pinOnSave?: boolean
showMinimalPlaceholder?: boolean
}) { }) {
const {data: preferences} = usePreferencesQuery() const {data: preferences} = usePreferencesQuery()
const {data: feed} = useFeedSourceInfoQuery({uri: feedUri}) const {data: feed} = useFeedSourceInfoQuery({uri: feedUri})
if (!feed || !preferences) {
return LoadingComponent ? (
LoadingComponent
) : (
<FeedLoadingPlaceholder style={{flex: 1}} />
)
}
return ( return (
<FeedSourceCardLoaded <FeedSourceCardLoaded
feedUri={feedUri}
feed={feed} feed={feed}
preferences={preferences} preferences={preferences}
style={style} style={style}
@ -63,11 +56,13 @@ export function FeedSourceCard({
showDescription={showDescription} showDescription={showDescription}
showLikes={showLikes} showLikes={showLikes}
pinOnSave={pinOnSave} pinOnSave={pinOnSave}
showMinimalPlaceholder={showMinimalPlaceholder}
/> />
) )
} }
export function FeedSourceCardLoaded({ export function FeedSourceCardLoaded({
feedUri,
feed, feed,
preferences, preferences,
style, style,
@ -75,14 +70,17 @@ export function FeedSourceCardLoaded({
showDescription = false, showDescription = false,
showLikes = false, showLikes = false,
pinOnSave = false, pinOnSave = false,
showMinimalPlaceholder,
}: { }: {
feed: FeedSourceInfo feedUri: string
preferences: UsePreferencesQueryResponse feed?: FeedSourceInfo
preferences?: UsePreferencesQueryResponse
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
showSaveBtn?: boolean showSaveBtn?: boolean
showDescription?: boolean showDescription?: boolean
showLikes?: boolean showLikes?: boolean
pinOnSave?: boolean pinOnSave?: boolean
showMinimalPlaceholder?: boolean
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
@ -95,7 +93,7 @@ export function FeedSourceCardLoaded({
useRemoveFeedMutation() useRemoveFeedMutation()
const {isPending: isPinPending, mutateAsync: pinFeed} = usePinFeedMutation() const {isPending: isPinPending, mutateAsync: pinFeed} = usePinFeedMutation()
const isSaved = Boolean(preferences?.feeds?.saved?.includes(feed.uri)) const isSaved = Boolean(preferences?.feeds?.saved?.includes(feed?.uri || ''))
const onToggleSaved = React.useCallback(async () => { const onToggleSaved = React.useCallback(async () => {
// Only feeds can be un/saved, lists are handled elsewhere // Only feeds can be un/saved, lists are handled elsewhere
@ -105,7 +103,7 @@ export function FeedSourceCardLoaded({
openModal({ openModal({
name: 'confirm', name: 'confirm',
title: _(msg`Remove from my feeds`), title: _(msg`Remove from my feeds`),
message: _(msg`Remove ${feed.displayName} from my feeds?`), message: _(msg`Remove ${feed?.displayName} from my feeds?`),
onPressConfirm: async () => { onPressConfirm: async () => {
try { try {
await removeFeed({uri: feed.uri}) await removeFeed({uri: feed.uri})
@ -132,7 +130,70 @@ export function FeedSourceCardLoaded({
} }
}, [isSaved, openModal, feed, removeFeed, saveFeed, _, pinOnSave, pinFeed]) }, [isSaved, openModal, feed, removeFeed, saveFeed, _, pinOnSave, pinFeed])
if (!feed || !preferences) return null /*
* LOAD STATE
*
* This state also captures the scenario where a feed can't load for whatever
* reason.
*/
if (!feed || !preferences)
return (
<View
style={[
pal.border,
{
borderTopWidth: showMinimalPlaceholder ? 0 : 1,
flexDirection: 'row',
alignItems: 'center',
flex: 1,
paddingRight: 18,
},
]}>
{showMinimalPlaceholder ? (
<FeedLoadingPlaceholder
style={{flex: 1}}
showTopBorder={false}
showLowerPlaceholder={false}
/>
) : (
<FeedLoadingPlaceholder style={{flex: 1}} showTopBorder={false} />
)}
{showSaveBtn && (
<Pressable
testID={`feed-${feedUri}-toggleSave`}
disabled={isRemovePending}
accessibilityRole="button"
accessibilityLabel={'Remove from my feeds'}
accessibilityHint=""
onPress={() => {
openModal({
name: 'confirm',
title: _(msg`Remove from my feeds`),
message: _(msg`Remove this feed from my feeds?`),
onPressConfirm: async () => {
try {
await removeFeed({uri: feedUri})
// await item.unsave()
Toast.show('Removed from my feeds')
} catch (e) {
Toast.show('There was an issue contacting your server')
logger.error('Failed to unsave feed', {error: e})
}
},
})
}}
hitSlop={15}
style={styles.btn}>
<FontAwesomeIcon
icon={['far', 'trash-can']}
size={19}
color={pal.colors.icon}
/>
</Pressable>
)}
</View>
)
return ( return (
<Pressable <Pressable

View File

@ -172,6 +172,7 @@ export const ProfileFeedgens = React.forwardRef<
if (preferences) { if (preferences) {
return ( return (
<FeedSourceCardLoaded <FeedSourceCardLoaded
feedUri={item.uri}
feed={item} feed={item}
preferences={preferences} preferences={preferences}
style={styles.item} style={styles.item}

View File

@ -214,7 +214,7 @@ export function FeedLoadingPlaceholder({
pal.border, pal.border,
style, style,
]}> ]}>
<View style={[pal.view, {flexDirection: 'row', marginBottom: 10}]}> <View style={[pal.view, {flexDirection: 'row'}]}>
<LoadingPlaceholder <LoadingPlaceholder
width={36} width={36}
height={36} height={36}
@ -226,7 +226,7 @@ export function FeedLoadingPlaceholder({
</View> </View>
</View> </View>
{showLowerPlaceholder && ( {showLowerPlaceholder && (
<View style={{paddingHorizontal: 5}}> <View style={{paddingHorizontal: 5, marginTop: 10}}>
<LoadingPlaceholder <LoadingPlaceholder
width={260} width={260}
height={8} height={8}

View File

@ -26,7 +26,6 @@ import {
useUnpinFeedMutation, useUnpinFeedMutation,
useSetSaveFeedsMutation, useSetSaveFeedsMutation,
} from '#/state/queries/preferences' } from '#/state/queries/preferences'
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
const HITSLOP_TOP = { const HITSLOP_TOP = {
top: 20, top: 20,
@ -89,6 +88,7 @@ export function SavedFeeds({}: Props) {
<Trans>Pinned Feeds</Trans> <Trans>Pinned Feeds</Trans>
</Text> </Text>
</View> </View>
{preferences?.feeds ? ( {preferences?.feeds ? (
!currentFeeds.pinned.length ? ( !currentFeeds.pinned.length ? (
<View <View
@ -290,13 +290,7 @@ function ListItem({
feedUri={feedUri} feedUri={feedUri}
style={styles.noBorder} style={styles.noBorder}
showSaveBtn showSaveBtn
LoadingComponent={ showMinimalPlaceholder
<FeedLoadingPlaceholder
style={{flex: 1}}
showLowerPlaceholder={false}
showTopBorder={false}
/>
}
/> />
<Pressable <Pressable
disabled={isPending} disabled={isPending}