about summary refs log tree commit diff
path: root/src/state/queries/search-posts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/queries/search-posts.ts')
-rw-r--r--src/state/queries/search-posts.ts33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/state/queries/search-posts.ts b/src/state/queries/search-posts.ts
index 5bee96535..f71d64255 100644
--- a/src/state/queries/search-posts.ts
+++ b/src/state/queries/search-posts.ts
@@ -1,4 +1,8 @@
-import {AppBskyFeedDefs, AppBskyFeedSearchPosts} from '@atproto/api'
+import {
+  AppBskyActorDefs,
+  AppBskyFeedDefs,
+  AppBskyFeedSearchPosts,
+} from '@atproto/api'
 import {
   InfiniteData,
   QueryClient,
@@ -75,3 +79,30 @@ export function* findAllPostsInQueryData(
     }
   }
 }
+
+export function* findAllProfilesInQueryData(
+  queryClient: QueryClient,
+  did: string,
+): Generator<AppBskyActorDefs.ProfileView, undefined> {
+  const queryDatas = queryClient.getQueriesData<
+    InfiniteData<AppBskyFeedSearchPosts.OutputSchema>
+  >({
+    queryKey: [searchPostsQueryKeyRoot],
+  })
+  for (const [_queryKey, queryData] of queryDatas) {
+    if (!queryData?.pages) {
+      continue
+    }
+    for (const page of queryData?.pages) {
+      for (const post of page.posts) {
+        if (post.author.did === did) {
+          yield post.author
+        }
+        const quotedPost = getEmbeddedPost(post.embed)
+        if (quotedPost?.author.did === did) {
+          yield quotedPost.author
+        }
+      }
+    }
+  }
+}