From 0f5b3808f8107ff4f04cda8c3da18ffcdcf6f27f Mon Sep 17 00:00:00 2001
From: Paul Frazee <pfrazee@gmail.com>
Date: Wed, 17 May 2023 15:03:19 -0500
Subject: Remove a focus-effect that was triggering a rerender loop

---
 src/view/com/util/post-embeds/index.tsx | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

(limited to 'src/view/com/util/post-embeds/index.tsx')

diff --git a/src/view/com/util/post-embeds/index.tsx b/src/view/com/util/post-embeds/index.tsx
index 01d26db91..9eb140c2e 100644
--- a/src/view/com/util/post-embeds/index.tsx
+++ b/src/view/com/util/post-embeds/index.tsx
@@ -170,20 +170,28 @@ export function PostEmbeds({
     AppBskyEmbedRecord.isView(embed) &&
     AppBskyFeedDefs.isGeneratorView(embed.record)
   ) {
-    // TODO memoize this?
-    return (
-      <CustomFeed
-        item={new CustomFeedModel(store, embed.record)}
-        style={[pal.view, pal.border, styles.customFeedOuter]}
-        reloadOnFocus
-        showLikes
-      />
-    )
+    return <CustomFeedEmbed record={embed.record} />
   }
 
   return <View />
 }
 
+function CustomFeedEmbed({record}: {record: AppBskyFeedDefs.GeneratorView}) {
+  const pal = usePalette('default')
+  const store = useStores()
+  const item = React.useMemo(
+    () => new CustomFeedModel(store, record),
+    [store, record],
+  )
+  return (
+    <CustomFeed
+      item={item}
+      style={[pal.view, pal.border, styles.customFeedOuter]}
+      showLikes
+    />
+  )
+}
+
 const styles = StyleSheet.create({
   stackContainer: {
     gap: 6,
-- 
cgit 1.4.1

