about summary refs log tree commit diff
path: root/src/state/queries/video/video-upload.web.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/queries/video/video-upload.web.ts')
-rw-r--r--src/state/queries/video/video-upload.web.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/state/queries/video/video-upload.web.ts b/src/state/queries/video/video-upload.web.ts
index 123c60155..a8494970a 100644
--- a/src/state/queries/video/video-upload.web.ts
+++ b/src/state/queries/video/video-upload.web.ts
@@ -30,11 +30,8 @@ export const useUploadVideoMutation = ({
         name: `${nanoid(12)}.mp4`, // @TODO: make sure it's always mp4'
       })
 
-      if (!currentAccount?.service) {
-        throw new Error('User is not logged in')
-      }
+      const serviceAuthAud = getServiceAuthAudFromUrl(agent.dispatchUrl)
 
-      const serviceAuthAud = getServiceAuthAudFromUrl(currentAccount.service)
       if (!serviceAuthAud) {
         throw new Error('Agent does not have a PDS URL')
       }
@@ -43,11 +40,15 @@ export const useUploadVideoMutation = ({
         {
           aud: serviceAuthAud,
           lxm: 'com.atproto.repo.uploadBlob',
-          exp: Date.now() + 1000 * 60 * 30, // 30 minutes
+          exp: Date.now() / 1000 + 60 * 30, // 30 minutes
         },
       )
 
-      const bytes = await fetch(video.uri).then(res => res.arrayBuffer())
+      let bytes = video.bytes
+
+      if (!bytes) {
+        bytes = await fetch(video.uri).then(res => res.arrayBuffer())
+      }
 
       const xhr = new XMLHttpRequest()
       const res = await new Promise<AppBskyVideoDefs.JobStatus>(