Fix feed pagination on user profiles

zio/stable
Paul Frazee 2022-09-28 17:02:55 -05:00
parent b4ad0cff4b
commit cb5a575bc8
7 changed files with 12 additions and 9 deletions

View File

@ -17,6 +17,7 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
_reactKey: string = ''
// data
cursor: string = ''
uri: string = ''
author: GetFeedView.User = {did: '', name: '', displayName: ''}
repostedBy?: GetFeedView.User
@ -42,6 +43,7 @@ export class FeedViewItemModel implements GetFeedView.FeedItem {
}
copy(v: GetFeedView.FeedItem) {
this.cursor = v.cursor
this.uri = v.uri
this.author = v.author
this.repostedBy = v.repostedBy
@ -145,7 +147,7 @@ export class FeedViewModel {
get loadMoreCursor() {
if (this.hasContent) {
return this.feed[this.feed.length - 1].indexedAt
return this.feed[this.feed.length - 1].cursor
}
return undefined
}

View File

@ -10935,6 +10935,9 @@ var methodSchemas = [
"indexedAt"
],
properties: {
cursor: {
type: "string"
},
uri: {
type: "string"
},

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,7 @@ export interface OutputSchema {
feed: FeedItem[];
}
export interface FeedItem {
cursor?: string;
uri: string;
author: User;
repostedBy?: User;

File diff suppressed because one or more lines are too long

View File

@ -3,11 +3,8 @@ import {observer} from 'mobx-react-lite'
import {Text, View, FlatList} from 'react-native'
import {FeedViewModel, FeedViewItemModel} from '../../../state/models/feed-view'
import {FeedItem} from './FeedItem'
import {useStores} from '../../../state'
export const Feed = observer(function Feed({feed}: {feed: FeedViewModel}) {
const store = useStores()
// TODO optimize renderItem or FeedItem, we're getting this notice from RN: -prf
// VirtualizedList: You have a large list that is slow to update - make sure your
// renderItem function renders components that follow React performance best practices
@ -26,7 +23,7 @@ export const Feed = observer(function Feed({feed}: {feed: FeedViewModel}) {
{feed.isLoading && !feed.isRefreshing && !feed.hasContent && (
<Text>Loading...</Text>
)}
{feed.hasError && <Text>{feed.errorStr}</Text>}
{feed.hasError && <Text>{feed.error}</Text>}
{feed.hasContent && (
<FlatList
data={feed.feed.slice()}

View File

@ -80,7 +80,7 @@ export const Profile = observer(({visible, params}: ScreenParams) => {
} else if (profileUiState.feed.hasError) {
items.push({
_reactKey: '__error__',
error: profileUiState.feed.errorStr,
error: profileUiState.feed.error,
})
renderItem = (item: any) => (
<View style={s.p5}>