From c3d8beee6dc141ced2c41795f90b3309a2bc75a2 Mon Sep 17 00:00:00 2001
From: Eric Bailey <git@esb.lol>
Date: Fri, 2 Aug 2024 13:05:33 -0500
Subject: Respect labels on feeds and lists (#4818)

* Prep

* Pass in optional moderation to FeedCard

* Compute moderation decision, filter contentList contexts, pass into card

* Let's go a different route

* Filter from within search queries

* Use same search query for starter packs

* Filter lists from profile tabs

* Cleanup

* Filter from profile feeds

* Moderate post embeds

* Memoize

* Use ScreenHider on lists

* Hide both list types

* Fix crash on iOS in screen hider, fix lineheight

* Memoize renderItem

* Reuse objects to prevent re-renders
---
 src/view/com/feeds/ProfileFeedgens.tsx | 83 ++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 40 deletions(-)

(limited to 'src/view/com/feeds/ProfileFeedgens.tsx')

diff --git a/src/view/com/feeds/ProfileFeedgens.tsx b/src/view/com/feeds/ProfileFeedgens.tsx
index 831ab4d1d..6f98cc49a 100644
--- a/src/view/com/feeds/ProfileFeedgens.tsx
+++ b/src/view/com/feeds/ProfileFeedgens.tsx
@@ -129,46 +129,49 @@ export const ProfileFeedgens = React.forwardRef<
   // rendering
   // =
 
-  const renderItem = ({item, index}: ListRenderItemInfo<any>) => {
-    if (item === EMPTY) {
-      return (
-        <EmptyState
-          icon="hashtag"
-          message={_(msg`You have no feeds.`)}
-          testID="listsEmpty"
-        />
-      )
-    } else if (item === ERROR_ITEM) {
-      return (
-        <ErrorMessage message={cleanError(error)} onPressTryAgain={refetch} />
-      )
-    } else if (item === LOAD_MORE_ERROR_ITEM) {
-      return (
-        <LoadMoreRetryBtn
-          label={_(
-            msg`There was an issue fetching your lists. Tap here to try again.`,
-          )}
-          onPress={onPressRetryLoadMore}
-        />
-      )
-    } else if (item === LOADING) {
-      return <FeedLoadingPlaceholder />
-    }
-    if (preferences) {
-      return (
-        <View
-          style={[
-            (index !== 0 || isWeb) && a.border_t,
-            t.atoms.border_contrast_low,
-            a.px_lg,
-            a.py_lg,
-          ]}>
-          <FeedCard.Default view={item} />
-        </View>
-      )
-    }
-    return null
-  }
+  const renderItem = React.useCallback(
+    ({item, index}: ListRenderItemInfo<any>) => {
+      if (item === EMPTY) {
+        return (
+          <EmptyState
+            icon="hashtag"
+            message={_(msg`You have no feeds.`)}
+            testID="listsEmpty"
+          />
+        )
+      } else if (item === ERROR_ITEM) {
+        return (
+          <ErrorMessage message={cleanError(error)} onPressTryAgain={refetch} />
+        )
+      } else if (item === LOAD_MORE_ERROR_ITEM) {
+        return (
+          <LoadMoreRetryBtn
+            label={_(
+              msg`There was an issue fetching your lists. Tap here to try again.`,
+            )}
+            onPress={onPressRetryLoadMore}
+          />
+        )
+      } else if (item === LOADING) {
+        return <FeedLoadingPlaceholder />
+      }
+      if (preferences) {
+        return (
+          <View
+            style={[
+              (index !== 0 || isWeb) && a.border_t,
+              t.atoms.border_contrast_low,
+              a.px_lg,
+              a.py_lg,
+            ]}>
+            <FeedCard.Default view={item} />
+          </View>
+        )
+      }
+      return null
+    },
+    [_, t, error, refetch, onPressRetryLoadMore, preferences],
+  )
 
   React.useEffect(() => {
     if (enabled && scrollElRef.current) {
-- 
cgit 1.4.1

