about summary refs log tree commit diff
path: root/src/state/cache
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-08-21 22:16:03 -0500
committerGitHub <noreply@github.com>2024-08-21 20:16:03 -0700
commitd5c78b9183ac78620f59538fed61c8130ae1c47a (patch)
tree53ad7c63b9263e508df587aa6d837c4036f394e9 /src/state/cache
parent61f0be705d614a31331945e1c4b9361d71b81403 (diff)
downloadvoidsky-d5c78b9183ac78620f59538fed61c8130ae1c47a.tar.zst
Prep threadgate shadow hack (#4970)
Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/state/cache')
-rw-r--r--src/state/cache/post-shadow.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/state/cache/post-shadow.ts b/src/state/cache/post-shadow.ts
index 65300a8ef..4d848ccc4 100644
--- a/src/state/cache/post-shadow.ts
+++ b/src/state/cache/post-shadow.ts
@@ -21,6 +21,7 @@ export interface PostShadow {
   repostUri: string | undefined
   isDeleted: boolean
   embed: AppBskyEmbedRecord.View | AppBskyEmbedRecordWithMedia.View | undefined
+  threadgateView: AppBskyFeedDefs.ThreadgateView | undefined
 }
 
 export const POST_TOMBSTONE = Symbol('PostTombstone')
@@ -104,6 +105,16 @@ function mergeShadow(
     }
   }
 
+  let threadgateView: typeof post.threadgate
+  if ('threadgateView' in shadow && !post.threadgate) {
+    if (
+      AppBskyFeedDefs.isThreadgateView(shadow.threadgateView) ||
+      shadow.threadgateView === undefined
+    ) {
+      threadgateView = shadow.threadgateView
+    }
+  }
+
   return castAsShadow({
     ...post,
     embed: embed || post.embed,
@@ -114,6 +125,8 @@ function mergeShadow(
       like: 'likeUri' in shadow ? shadow.likeUri : post.viewer?.like,
       repost: 'repostUri' in shadow ? shadow.repostUri : post.viewer?.repost,
     },
+    // always prefer real post data
+    threadgate: post.threadgate || threadgateView,
   })
 }