about summary refs log tree commit diff
path: root/src/state/models/discovery/feeds.ts
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-07-28 08:29:37 -0700
committerGitHub <noreply@github.com>2023-07-28 10:29:37 -0500
commit38d78e16bffc9a25a45a4ad41caeef2c075daa26 (patch)
tree091bd4a86548899d64ad904c7f0fbf1fbb745778 /src/state/models/discovery/feeds.ts
parent8e9b8b6b36bc5bb68737b783ae6accfd435fda8e (diff)
downloadvoidsky-38d78e16bffc9a25a45a4ad41caeef2c075daa26.tar.zst
Search custom feeds (#1031)
* paginate custom feeds

* basic search

* update `@atproto/api`

* use search from the API

* debounce search for 200ms
Diffstat (limited to 'src/state/models/discovery/feeds.ts')
-rw-r--r--src/state/models/discovery/feeds.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/state/models/discovery/feeds.ts b/src/state/models/discovery/feeds.ts
index c484f7328..fa4054ff0 100644
--- a/src/state/models/discovery/feeds.ts
+++ b/src/state/models/discovery/feeds.ts
@@ -82,6 +82,21 @@ export class FeedsDiscoveryModel {
     this._xIdle()
   })
 
+  search = async (query: string) => {
+    this._xLoading(false)
+    try {
+      const results =
+        await this.rootStore.agent.app.bsky.unspecced.getPopularFeedGenerators({
+          limit: DEFAULT_LIMIT,
+          query: query,
+        })
+      this._replaceAll(results)
+    } catch (e: any) {
+      this._xIdle(e)
+    }
+    this._xIdle()
+  }
+
   clear() {
     this.isLoading = false
     this.isRefreshing = false
@@ -93,9 +108,9 @@ export class FeedsDiscoveryModel {
   // state transitions
   // =
 
-  _xLoading() {
+  _xLoading(isRefreshing = true) {
     this.isLoading = true
-    this.isRefreshing = true
+    this.isRefreshing = isRefreshing
     this.error = ''
   }