about summary refs log tree commit diff
path: root/src/lib/hooks/useFollowDid.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-10-05 16:44:05 -0700
committerGitHub <noreply@github.com>2023-10-05 16:44:05 -0700
commitbd7db8af26bfbf94a80972671ca714a143bee28e (patch)
treecf022bddc4f6b164bea51aeb3c57479d72b73355 /src/lib/hooks/useFollowDid.ts
parent19f8389fc777c7ff41466748f1238f4e0a4b0619 (diff)
downloadvoidsky-bd7db8af26bfbf94a80972671ca714a143bee28e.tar.zst
Improve typeahead search with inclusion of followed users (temporary solution) (#1612)
* Update follows cache to maintain some user info

* Prioritize follows in composer autocomplete

* Clean up logic and add new autocomplete to search

* Update follow hook
Diffstat (limited to 'src/lib/hooks/useFollowDid.ts')
-rw-r--r--src/lib/hooks/useFollowDid.ts46
1 files changed, 0 insertions, 46 deletions
diff --git a/src/lib/hooks/useFollowDid.ts b/src/lib/hooks/useFollowDid.ts
deleted file mode 100644
index 223adb047..000000000
--- a/src/lib/hooks/useFollowDid.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import React from 'react'
-
-import {useStores} from 'state/index'
-import {FollowState} from 'state/models/cache/my-follows'
-
-export function useFollowDid({did}: {did: string}) {
-  const store = useStores()
-  const state = store.me.follows.getFollowState(did)
-
-  return {
-    state,
-    following: state === FollowState.Following,
-    toggle: React.useCallback(async () => {
-      if (state === FollowState.Following) {
-        try {
-          await store.agent.deleteFollow(store.me.follows.getFollowUri(did))
-          store.me.follows.removeFollow(did)
-          return {
-            state: FollowState.NotFollowing,
-            following: false,
-          }
-        } catch (e: any) {
-          store.log.error('Failed to delete follow', e)
-          throw e
-        }
-      } else if (state === FollowState.NotFollowing) {
-        try {
-          const res = await store.agent.follow(did)
-          store.me.follows.addFollow(did, res.uri)
-          return {
-            state: FollowState.Following,
-            following: true,
-          }
-        } catch (e: any) {
-          store.log.error('Failed to create follow', e)
-          throw e
-        }
-      }
-
-      return {
-        state: FollowState.Unknown,
-        following: false,
-      }
-    }, [store, did, state]),
-  }
-}