Improve feed reordering with optimistic updates (#2032)
* Optimisticaly update order of saved feeds * Better show disabled state for pin button * Improve loading/disabled states * Improve placeholder * Simplify loading components
This commit is contained in:
parent
3ca4bd805a
commit
a59d235e8b
3 changed files with 115 additions and 57 deletions
|
@ -23,6 +23,7 @@ import {
|
|||
useRemoveFeedMutation,
|
||||
} from '#/state/queries/preferences'
|
||||
import {useFeedSourceInfoQuery, FeedSourceInfo} from '#/state/queries/feed'
|
||||
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
||||
|
||||
export function FeedSourceCard({
|
||||
feedUri,
|
||||
|
@ -30,17 +31,25 @@ export function FeedSourceCard({
|
|||
showSaveBtn = false,
|
||||
showDescription = false,
|
||||
showLikes = false,
|
||||
LoadingComponent,
|
||||
}: {
|
||||
feedUri: string
|
||||
style?: StyleProp<ViewStyle>
|
||||
showSaveBtn?: boolean
|
||||
showDescription?: boolean
|
||||
showLikes?: boolean
|
||||
LoadingComponent?: JSX.Element
|
||||
}) {
|
||||
const {data: preferences} = usePreferencesQuery()
|
||||
const {data: feed} = useFeedSourceInfoQuery({uri: feedUri})
|
||||
|
||||
if (!feed || !preferences) return null
|
||||
if (!feed || !preferences) {
|
||||
return LoadingComponent ? (
|
||||
LoadingComponent
|
||||
) : (
|
||||
<FeedLoadingPlaceholder style={{flex: 1}} />
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<FeedSourceCardLoaded
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue