about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-06-17 11:22:39 -0500
committerGitHub <noreply@github.com>2024-06-17 19:22:39 +0300
commitf5f3bd8130c1ba1fee4030f758a158a983ff28c5 (patch)
tree75b3828424cc6d4b97d64b58ceb996102941d113 /src
parentba2fadb661a9523667fd96e8e8fcb67ac4912792 (diff)
downloadvoidsky-f5f3bd8130c1ba1fee4030f758a158a983ff28c5.tar.zst
Select, don't mutate (#4541)
Diffstat (limited to 'src')
-rw-r--r--src/state/queries/feed.ts40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/state/queries/feed.ts b/src/state/queries/feed.ts
index 2981b41b4..83d6a7634 100644
--- a/src/state/queries/feed.ts
+++ b/src/state/queries/feed.ts
@@ -234,26 +234,28 @@ export function useGetPopularFeedsQuery(options?: GetPopularFeedsOptions) {
         data: InfiniteData<AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema>,
       ) => {
         const {savedFeeds, hasSession: hasSessionInner} = selectArgs
-        data?.pages.map(page => {
-          page.feeds = page.feeds.filter(feed => {
-            if (
-              !hasSessionInner &&
-              KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri)
-            ) {
-              return false
-            }
-            const alreadySaved = Boolean(
-              savedFeeds?.find(f => {
-                return f.value === feed.uri
+        return {
+          ...data,
+          pages: data.pages.map(page => {
+            return {
+              ...page,
+              feeds: page.feeds.filter(feed => {
+                if (
+                  !hasSessionInner &&
+                  KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri)
+                ) {
+                  return false
+                }
+                const alreadySaved = Boolean(
+                  savedFeeds?.find(f => {
+                    return f.value === feed.uri
+                  }),
+                )
+                return !alreadySaved
               }),
-            )
-            return !alreadySaved
-          })
-
-          return page
-        })
-
-        return data
+            }
+          }),
+        }
       },
       [selectArgs /* Don't change. Everything needs to go into selectArgs. */],
     ),