@@ -22,15 +22,15 @@ import {cleanError} from '#/lib/strings/errors'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isIOS, isNative, isWeb} from '#/platform/detection'
|
import {isIOS, isNative, isWeb} from '#/platform/detection'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {RQKEY, useProfileFeedgensQuery} from '#/state/queries/profile-feedgens'
|
import {RQKEY, useProfileListsQuery} from '#/state/queries/profile-lists'
|
||||||
import {EmptyState} from '#/view/com/util/EmptyState'
|
import {EmptyState} from '#/view/com/util/EmptyState'
|
||||||
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
||||||
import {List, type ListRef} from '#/view/com/util/List'
|
import {List, type ListRef} from '#/view/com/util/List'
|
||||||
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
||||||
import {LoadMoreRetryBtn} from '#/view/com/util/LoadMoreRetryBtn'
|
import {LoadMoreRetryBtn} from '#/view/com/util/LoadMoreRetryBtn'
|
||||||
import {atoms as a, ios, useTheme} from '#/alf'
|
import {atoms as a, ios, useTheme} from '#/alf'
|
||||||
import * as FeedCard from '#/components/FeedCard'
|
|
||||||
import {BulletList_Stroke1_Corner0_Rounded as ListIcon} from '#/components/icons/BulletList'
|
import {BulletList_Stroke1_Corner0_Rounded as ListIcon} from '#/components/icons/BulletList'
|
||||||
|
import * as ListCard from '#/components/ListCard'
|
||||||
import {ListFooter} from '#/components/Lists'
|
import {ListFooter} from '#/components/Lists'
|
||||||
|
|
||||||
const LOADING = {_reactKey: '__loading__'}
|
const LOADING = {_reactKey: '__loading__'}
|
||||||
@@ -42,7 +42,7 @@ interface SectionRef {
|
|||||||
scrollToTop: () => void
|
scrollToTop: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProfileFeedgensProps {
|
interface ProfileListsProps {
|
||||||
ref?: React.Ref<SectionRef>
|
ref?: React.Ref<SectionRef>
|
||||||
did: string
|
did: string
|
||||||
scrollElRef: ListRef
|
scrollElRef: ListRef
|
||||||
@@ -62,7 +62,7 @@ export function ProfileLists({
|
|||||||
style,
|
style,
|
||||||
testID,
|
testID,
|
||||||
setScrollViewTag,
|
setScrollViewTag,
|
||||||
}: ProfileFeedgensProps) {
|
}: ProfileListsProps) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const [isPTRing, setIsPTRing] = useState(false)
|
const [isPTRing, setIsPTRing] = useState(false)
|
||||||
@@ -77,8 +77,8 @@ export function ProfileLists({
|
|||||||
isError,
|
isError,
|
||||||
error,
|
error,
|
||||||
refetch,
|
refetch,
|
||||||
} = useProfileFeedgensQuery(did, opts)
|
} = useProfileListsQuery(did, opts)
|
||||||
const isEmpty = !isPending && !data?.pages[0]?.feeds.length
|
const isEmpty = !isPending && !data?.pages[0]?.lists.length
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation()
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ export function ProfileLists({
|
|||||||
items = items.concat([EMPTY])
|
items = items.concat([EMPTY])
|
||||||
} else if (data?.pages) {
|
} else if (data?.pages) {
|
||||||
for (const page of data?.pages) {
|
for (const page of data?.pages) {
|
||||||
items = items.concat(page.feeds)
|
items = items.concat(page.lists)
|
||||||
}
|
}
|
||||||
} else if (isError && !isEmpty) {
|
} else if (isError && !isEmpty) {
|
||||||
items = items.concat([LOAD_MORE_ERROR_ITEM])
|
items = items.concat([LOAD_MORE_ERROR_ITEM])
|
||||||
@@ -123,7 +123,7 @@ export function ProfileLists({
|
|||||||
try {
|
try {
|
||||||
await refetch()
|
await refetch()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Failed to refresh feeds', {message: err})
|
logger.error('Failed to refresh lists', {message: err})
|
||||||
}
|
}
|
||||||
setIsPTRing(false)
|
setIsPTRing(false)
|
||||||
}, [refetch, setIsPTRing])
|
}, [refetch, setIsPTRing])
|
||||||
@@ -134,7 +134,7 @@ export function ProfileLists({
|
|||||||
try {
|
try {
|
||||||
await fetchNextPage()
|
await fetchNextPage()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Failed to load more feeds', {message: err})
|
logger.error('Failed to load more lists', {message: err})
|
||||||
}
|
}
|
||||||
}, [isFetchingNextPage, hasNextPage, isError, fetchNextPage])
|
}, [isFetchingNextPage, hasNextPage, isError, fetchNextPage])
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ export function ProfileLists({
|
|||||||
a.px_lg,
|
a.px_lg,
|
||||||
a.py_lg,
|
a.py_lg,
|
||||||
]}>
|
]}>
|
||||||
<FeedCard.Default view={item} />
|
<ListCard.Default view={item} />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ export function ProfileLists({
|
|||||||
}
|
}
|
||||||
}, [enabled, scrollElRef, setScrollViewTag])
|
}, [enabled, scrollElRef, setScrollViewTag])
|
||||||
|
|
||||||
const ProfileFeedgensFooter = useCallback(() => {
|
const ProfileListsFooter = useCallback(() => {
|
||||||
if (isEmpty) return null
|
if (isEmpty) return null
|
||||||
return (
|
return (
|
||||||
<ListFooter
|
<ListFooter
|
||||||
@@ -233,7 +233,7 @@ export function ProfileLists({
|
|||||||
data={items}
|
data={items}
|
||||||
keyExtractor={keyExtractor}
|
keyExtractor={keyExtractor}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
ListFooterComponent={ProfileFeedgensFooter}
|
ListFooterComponent={ProfileListsFooter}
|
||||||
refreshing={isPTRing}
|
refreshing={isPTRing}
|
||||||
onRefresh={onRefresh}
|
onRefresh={onRefresh}
|
||||||
headerOffset={headerOffset}
|
headerOffset={headerOffset}
|
||||||
|
|||||||
Reference in New Issue
Block a user