Fix feed pagination on user profiles

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

View file

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

File diff suppressed because one or more lines are too long

View file

@ -12,6 +12,7 @@ export interface OutputSchema {
feed: FeedItem[]; feed: FeedItem[];
} }
export interface FeedItem { export interface FeedItem {
cursor?: string;
uri: string; uri: string;
author: User; author: User;
repostedBy?: 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 {Text, View, FlatList} from 'react-native'
import {FeedViewModel, FeedViewItemModel} from '../../../state/models/feed-view' import {FeedViewModel, FeedViewItemModel} from '../../../state/models/feed-view'
import {FeedItem} from './FeedItem' import {FeedItem} from './FeedItem'
import {useStores} from '../../../state'
export const Feed = observer(function Feed({feed}: {feed: FeedViewModel}) { 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 // 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 // VirtualizedList: You have a large list that is slow to update - make sure your
// renderItem function renders components that follow React performance best practices // 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 && ( {feed.isLoading && !feed.isRefreshing && !feed.hasContent && (
<Text>Loading...</Text> <Text>Loading...</Text>
)} )}
{feed.hasError && <Text>{feed.errorStr}</Text>} {feed.hasError && <Text>{feed.error}</Text>}
{feed.hasContent && ( {feed.hasContent && (
<FlatList <FlatList
data={feed.feed.slice()} data={feed.feed.slice()}

View file

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