Lex refactor fixes (#368)

* Fix: handle validation failures correctly in feed-view

* Fix: convert the off-spec feed view to lex objects

* Fix to fetching all follows during init

* Bump @atproto/api@0.2.1

* Fix: properly group together like notifications

* 1.12
This commit is contained in:
Paul Frazee 2023-04-02 14:20:19 -05:00 committed by GitHub
parent 14965d4d97
commit cc7b2a246e
9 changed files with 28 additions and 11 deletions

View file

@ -57,6 +57,7 @@ export class MyFollowsCache {
await this.rootStore.agent.app.bsky.graph.follow.list({
repo: this.rootStore.me.did,
rkeyStart,
reverse: true,
})
records = records.concat(res.records)
rkeyStart = res.cursor

View file

@ -5,6 +5,7 @@ import {
AppBskyFeedPost,
AppBskyFeedGetAuthorFeed as GetAuthorFeed,
RichText,
jsonToLex,
} from '@atproto/api'
import AwaitLock from 'await-lock'
import {bundleAsync} from 'lib/async/bundle'
@ -50,12 +51,16 @@ export class FeedItemModel {
this.postRecord = this.post.record
this.richText = new RichText(this.postRecord, {cleanNewlines: true})
} else {
this.postRecord = undefined
this.richText = undefined
rootStore.log.warn(
'Received an invalid app.bsky.feed.post record',
valid.error,
)
}
} else {
this.postRecord = undefined
this.richText = undefined
rootStore.log.warn(
'app.bsky.feed.getTimeline or app.bsky.feed.getAuthorFeed served an unexpected record type',
this.post.record,
@ -634,6 +639,6 @@ async function getGoodStuff(
return {
success: res.status === 200,
headers: resHeaders,
data: resBody,
data: jsonToLex(resBody),
}
}

View file

@ -97,7 +97,7 @@ export class LikesViewModel {
this.hasLoaded = true
this.error = cleanError(err)
if (err) {
this.rootStore.log.error('Failed to fetch votes', err)
this.rootStore.log.error('Failed to fetch likes', err)
}
}

View file

@ -13,7 +13,7 @@ import {RootStoreModel} from './root-store'
import {PostThreadViewModel} from './post-thread-view'
import {cleanError} from 'lib/strings/errors'
const GROUPABLE_REASONS = ['vote', 'repost', 'follow']
const GROUPABLE_REASONS = ['like', 'repost', 'follow']
const PAGE_SIZE = 30
const MS_1HR = 1e3 * 60 * 60
const MS_2DAY = MS_1HR * 48

View file

@ -8,7 +8,7 @@ import {ProfileCardWithFollowBtn} from '../profile/ProfileCard'
import {useStores} from 'state/index'
import {usePalette} from 'lib/hooks/usePalette'
export const PostLikedBy = observer(function PostVotedBy({uri}: {uri: string}) {
export const PostLikedBy = observer(function ({uri}: {uri: string}) {
const pal = usePalette('default')
const store = useStores()
const view = React.useMemo(
@ -17,7 +17,7 @@ export const PostLikedBy = observer(function PostVotedBy({uri}: {uri: string}) {
)
useEffect(() => {
view.loadMore().catch(err => store.log.error('Failed to fetch votes', err))
view.loadMore().catch(err => store.log.error('Failed to fetch likes', err))
}, [view, store.log])
const onRefresh = () => {
@ -26,7 +26,7 @@ export const PostLikedBy = observer(function PostVotedBy({uri}: {uri: string}) {
const onEndReached = () => {
view
.loadMore()
.catch(err => view?.rootStore.log.error('Failed to load more votes', err))
.catch(err => view?.rootStore.log.error('Failed to load more likes', err))
}
if (!view.hasLoaded) {