Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix optimistic like/repost (#3503)

authored by

dan and committed by
GitHub
7047755c f3951f27

+18 -14
+18 -14
src/state/cache/post-shadow.ts
··· 62 62 return POST_TOMBSTONE 63 63 } 64 64 65 - const wasLiked = !!post.viewer?.like 66 - const isLiked = !!shadow.likeUri 67 65 let likeCount = post.likeCount ?? 0 68 - if (wasLiked && !isLiked) { 69 - likeCount-- 70 - } else if (!wasLiked && isLiked) { 71 - likeCount++ 66 + if ('likeUri' in shadow) { 67 + const wasLiked = !!post.viewer?.like 68 + const isLiked = !!shadow.likeUri 69 + if (wasLiked && !isLiked) { 70 + likeCount-- 71 + } else if (!wasLiked && isLiked) { 72 + likeCount++ 73 + } 74 + likeCount = Math.max(0, likeCount) 72 75 } 73 - likeCount = Math.max(0, likeCount) 74 76 75 - const wasReposted = !!post.viewer?.repost 76 - const isReposted = !!shadow.repostUri 77 77 let repostCount = post.repostCount ?? 0 78 - if (wasReposted && !isReposted) { 79 - repostCount-- 80 - } else if (!wasReposted && isReposted) { 81 - repostCount++ 78 + if ('repostUri' in shadow) { 79 + const wasReposted = !!post.viewer?.repost 80 + const isReposted = !!shadow.repostUri 81 + if (wasReposted && !isReposted) { 82 + repostCount-- 83 + } else if (!wasReposted && isReposted) { 84 + repostCount++ 85 + } 86 + repostCount = Math.max(0, repostCount) 82 87 } 83 - repostCount = Math.max(0, repostCount) 84 88 85 89 return castAsShadow({ 86 90 ...post,