about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-04-02 14:20:19 -0500
committerGitHub <noreply@github.com>2023-04-02 14:20:19 -0500
commitcc7b2a246ec5071f02bc81090b63b073b3d3614b (patch)
treeabc7378ab4a03c31e7d905d257166fdf2092d556 /src
parent14965d4d97aa51e189d06e8f3aebac6cbed49e82 (diff)
downloadvoidsky-cc7b2a246ec5071f02bc81090b63b073b3d3614b.tar.zst
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
Diffstat (limited to 'src')
-rw-r--r--src/state/models/cache/my-follows.ts1
-rw-r--r--src/state/models/feed-view.ts7
-rw-r--r--src/state/models/likes-view.ts2
-rw-r--r--src/state/models/notifications-view.ts2
-rw-r--r--src/view/com/post-thread/PostLikedBy.tsx6
5 files changed, 12 insertions, 6 deletions
diff --git a/src/state/models/cache/my-follows.ts b/src/state/models/cache/my-follows.ts
index 14eeaae21..eaab829bc 100644
--- a/src/state/models/cache/my-follows.ts
+++ b/src/state/models/cache/my-follows.ts
@@ -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
diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts
index 8b62c958f..349723fbb 100644
--- a/src/state/models/feed-view.ts
+++ b/src/state/models/feed-view.ts
@@ -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),
   }
 }
diff --git a/src/state/models/likes-view.ts b/src/state/models/likes-view.ts
index 5f9df692e..80e0be0ef 100644
--- a/src/state/models/likes-view.ts
+++ b/src/state/models/likes-view.ts
@@ -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)
     }
   }
 
diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts
index 4f7a52fd9..7089f0125 100644
--- a/src/state/models/notifications-view.ts
+++ b/src/state/models/notifications-view.ts
@@ -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
diff --git a/src/view/com/post-thread/PostLikedBy.tsx b/src/view/com/post-thread/PostLikedBy.tsx
index 9fb46702e..3ca147b8d 100644
--- a/src/view/com/post-thread/PostLikedBy.tsx
+++ b/src/view/com/post-thread/PostLikedBy.tsx
@@ -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) {