about summary refs log tree commit diff
path: root/src/lib/api/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/api/index.ts')
-rw-r--r--src/lib/api/index.ts23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts
index f727aa4ca..46dbd1e66 100644
--- a/src/lib/api/index.ts
+++ b/src/lib/api/index.ts
@@ -30,14 +30,18 @@ import {
   createThreadgateRecord,
   threadgateAllowUISettingToAllowRecordValue,
 } from '#/state/queries/threadgate'
-import {ComposerDraft, EmbedDraft} from '#/view/com/composer/state/composer'
+import {
+  EmbedDraft,
+  PostDraft,
+  ThreadDraft,
+} from '#/view/com/composer/state/composer'
 import {createGIFDescription} from '../gif-alt-text'
 import {uploadBlob} from './upload-blob'
 
 export {uploadBlob}
 
 interface PostOpts {
-  draft: ComposerDraft
+  thread: ThreadDraft
   replyTo?: string
   onStateChange?: (state: string) => void
   langs?: string[]
@@ -48,7 +52,8 @@ export async function post(
   queryClient: QueryClient,
   opts: PostOpts,
 ) {
-  const draft = opts.draft
+  const thread = opts.thread
+  const draft = thread.posts[0] // TODO: Support threads.
 
   opts.onStateChange?.(t`Processing...`)
   // NB -- Do not await anything here to avoid waterfalls!
@@ -111,11 +116,11 @@ export async function post(
   }
 
   // Create threadgate record
-  if (draft.threadgate.some(tg => tg.type !== 'everybody')) {
+  if (thread.threadgate.some(tg => tg.type !== 'everybody')) {
     const record = createThreadgateRecord({
       createdAt: date,
       post: uri,
-      allow: threadgateAllowUISettingToAllowRecordValue(draft.threadgate),
+      allow: threadgateAllowUISettingToAllowRecordValue(thread.threadgate),
     })
 
     writes.push({
@@ -128,11 +133,11 @@ export async function post(
 
   // Create postgate record
   if (
-    draft.postgate.embeddingRules?.length ||
-    draft.postgate.detachedEmbeddingUris?.length
+    thread.postgate.embeddingRules?.length ||
+    thread.postgate.detachedEmbeddingUris?.length
   ) {
     const record: AppBskyFeedPostgate.Record = {
-      ...draft.postgate,
+      ...thread.postgate,
       $type: 'app.bsky.feed.postgate',
       createdAt: date,
       post: uri,
@@ -198,7 +203,7 @@ async function resolveReply(agent: BskyAgent, replyTo: string) {
 async function resolveEmbed(
   agent: BskyAgent,
   queryClient: QueryClient,
-  draft: ComposerDraft,
+  draft: PostDraft,
   onStateChange: ((state: string) => void) | undefined,
 ): Promise<
   | AppBskyEmbedImages.Main