···175175}> {
176176 const postUris = new Set<string>()
177177 const packUris = new Set<string>()
178178-179179- const postUrisWithLikes = new Set<string>()
180180- const postUrisWithReposts = new Set<string>()
181181-182178 for (const notif of groupedNotifs) {
183179 if (notif.subjectUri?.includes('app.bsky.feed.post')) {
184180 postUris.add(notif.subjectUri)
185185- if (notif.type === 'post-like') {
186186- postUrisWithLikes.add(notif.subjectUri)
187187- }
188188- if (notif.type === 'repost') {
189189- postUrisWithReposts.add(notif.subjectUri)
190190- }
191181 } else if (
192182 notif.notification.reasonSubject?.includes('app.bsky.graph.starterpack')
193183 ) {
···216206 AppBskyFeedPost.validateRecord(post.record).success
217207 ) {
218208 postsMap.set(post.uri, post)
219219-220220- // HACK. In some cases, the appview appears to lag behind and returns empty counters.
221221- // To prevent scroll jump due to missing metrics, fill in 1 like/repost instead of 0.
222222- if (post.likeCount === 0 && postUrisWithLikes.has(post.uri)) {
223223- post.likeCount = 1
224224- }
225225- if (post.repostCount === 0 && postUrisWithReposts.has(post.uri)) {
226226- post.repostCount = 1
227227- }
228209 }
229210 }
230211 for (const pack of packsChunks.flat()) {
+6-2
src/state/queries/post-thread.ts
···408408 }
409409 }
410410 }
411411- for (let post of findAllPostsInFeedQueryData(queryClient, uri)) {
411411+ for (let post of findAllPostsInNotifsQueryData(queryClient, uri)) {
412412+ // Check notifications first. If you have a post in notifications,
413413+ // it's often due to a like or a repost, and we want to prioritize
414414+ // a post object with >0 likes/reposts over a stale version with no
415415+ // metrics in order to avoid a notification->post scroll jump.
412416 yield postViewToPlaceholderThread(post)
413417 }
414414- for (let post of findAllPostsInNotifsQueryData(queryClient, uri)) {
418418+ for (let post of findAllPostsInFeedQueryData(queryClient, uri)) {
415419 yield postViewToPlaceholderThread(post)
416420 }
417421 for (let post of findAllPostsInQuoteQueryData(queryClient, uri)) {