Notifs refresh improvement (#1941)
* Show loading state in notifications * Fix invalidation of notifs * Move spinner below header * Fix: dont show spinner on initial loadzio/stable
parent
6f57192bd5
commit
c03c744008
|
@ -39,6 +39,7 @@ export function Feed({
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
dataUpdatedAt,
|
dataUpdatedAt,
|
||||||
|
isLoading,
|
||||||
isFetching,
|
isFetching,
|
||||||
isFetched,
|
isFetched,
|
||||||
isError,
|
isError,
|
||||||
|
@ -139,6 +140,21 @@ export function Feed({
|
||||||
[onPressRetryLoadMore, dataUpdatedAt, moderationOpts],
|
[onPressRetryLoadMore, dataUpdatedAt, moderationOpts],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const showHeaderSpinner = !isPTRing && isFetching && !isLoading
|
||||||
|
const FeedHeader = React.useCallback(
|
||||||
|
() => (
|
||||||
|
<View>
|
||||||
|
{ListHeaderComponent ? <ListHeaderComponent /> : null}
|
||||||
|
{showHeaderSpinner ? (
|
||||||
|
<View style={{padding: 10}}>
|
||||||
|
<ActivityIndicator />
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
),
|
||||||
|
[ListHeaderComponent, showHeaderSpinner],
|
||||||
|
)
|
||||||
|
|
||||||
const FeedFooter = React.useCallback(
|
const FeedFooter = React.useCallback(
|
||||||
() =>
|
() =>
|
||||||
isFetchingNextPage ? (
|
isFetchingNextPage ? (
|
||||||
|
@ -168,7 +184,7 @@ export function Feed({
|
||||||
data={items}
|
data={items}
|
||||||
keyExtractor={item => item._reactKey}
|
keyExtractor={item => item._reactKey}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
ListHeaderComponent={ListHeaderComponent}
|
ListHeaderComponent={FeedHeader}
|
||||||
ListFooterComponent={FeedFooter}
|
ListFooterComponent={FeedFooter}
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl
|
<RefreshControl
|
||||||
|
|
|
@ -47,7 +47,9 @@ export const NotificationsScreen = withAuthRequired(
|
||||||
|
|
||||||
const onPressLoadLatest = React.useCallback(() => {
|
const onPressLoadLatest = React.useCallback(() => {
|
||||||
scrollToTop()
|
scrollToTop()
|
||||||
queryClient.invalidateQueries({queryKey: NOTIFS_RQKEY()})
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: NOTIFS_RQKEY(),
|
||||||
|
})
|
||||||
}, [scrollToTop, queryClient])
|
}, [scrollToTop, queryClient])
|
||||||
|
|
||||||
// on-visible setup
|
// on-visible setup
|
||||||
|
|
Loading…
Reference in New Issue