about summary refs log tree commit diff
path: root/src/lib/notifications/notifications.ts
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-05-28 16:37:51 +0100
committerGitHub <noreply@github.com>2024-05-28 16:37:51 +0100
commit9bd411c15159609803c4e8c3e352a9db32ea527c (patch)
tree31305e290bd4597aa6ab441ecc556999b19ad693 /src/lib/notifications/notifications.ts
parent8a2f43c218c464e6165f331e482b6094b87eefc7 (diff)
downloadvoidsky-9bd411c15159609803c4e8c3e352a9db32ea527c.tar.zst
Replace getAgent() with reading agent (#4243)
* Replace getAgent() with agent

* Replace {agent} with agent
Diffstat (limited to 'src/lib/notifications/notifications.ts')
-rw-r--r--src/lib/notifications/notifications.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts
index f9fbdb8bf..f0667b0cc 100644
--- a/src/lib/notifications/notifications.ts
+++ b/src/lib/notifications/notifications.ts
@@ -14,12 +14,12 @@ const SERVICE_DID = (serviceUrl?: string) =>
     : 'did:web:api.bsky.app'
 
 async function registerPushToken(
-  getAgent: () => BskyAgent,
+  agent: BskyAgent,
   account: SessionAccount,
   token: Notifications.DevicePushToken,
 ) {
   try {
-    await getAgent().api.app.bsky.notification.registerPush({
+    await agent.api.app.bsky.notification.registerPush({
       serviceDid: SERVICE_DID(account.service),
       platform: devicePlatform,
       token: token.data,
@@ -47,7 +47,7 @@ async function getPushToken(skipPermissionCheck = false) {
 }
 
 export function useNotificationsRegistration() {
-  const {getAgent} = useAgent()
+  const agent = useAgent()
   const {currentAccount} = useSession()
 
   React.useEffect(() => {
@@ -60,13 +60,13 @@ export function useNotificationsRegistration() {
     // According to the Expo docs, there is a chance that the token will change while the app is open in some rare
     // cases. This will fire `registerPushToken` whenever that happens.
     const subscription = Notifications.addPushTokenListener(async newToken => {
-      registerPushToken(getAgent, currentAccount, newToken)
+      registerPushToken(agent, currentAccount, newToken)
     })
 
     return () => {
       subscription.remove()
     }
-  }, [currentAccount, getAgent])
+  }, [currentAccount, agent])
 }
 
 export function useRequestNotificationsPermission() {