Add a few utils
This commit is contained in:
+11
-10
@@ -13,6 +13,7 @@ import {
|
|||||||
ComAtprotoRepoStrongRef,
|
ComAtprotoRepoStrongRef,
|
||||||
RichText,
|
RichText,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {$Typed} from '@atproto/api/dist/client/util'
|
||||||
import {TID} from '@atproto/common-web'
|
import {TID} from '@atproto/common-web'
|
||||||
import * as dcbor from '@ipld/dag-cbor'
|
import * as dcbor from '@ipld/dag-cbor'
|
||||||
import {t} from '@lingui/macro'
|
import {t} from '@lingui/macro'
|
||||||
@@ -74,7 +75,7 @@ export async function post(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const did = agent.assertDid
|
const did = agent.assertDid
|
||||||
const writes: ComAtprotoRepoApplyWrites.Create[] = []
|
const writes: $Typed<ComAtprotoRepoApplyWrites.Create>[] = []
|
||||||
const uris: string[] = []
|
const uris: string[] = []
|
||||||
|
|
||||||
let now = new Date()
|
let now = new Date()
|
||||||
@@ -91,7 +92,7 @@ export async function post(
|
|||||||
draft,
|
draft,
|
||||||
opts.onStateChange,
|
opts.onStateChange,
|
||||||
)
|
)
|
||||||
let labels: ComAtprotoLabelDefs.SelfLabels | undefined
|
let labels: $Typed<ComAtprotoLabelDefs.SelfLabels> | undefined
|
||||||
if (draft.labels.length) {
|
if (draft.labels.length) {
|
||||||
labels = {
|
labels = {
|
||||||
$type: 'com.atproto.label.defs#selfLabels',
|
$type: 'com.atproto.label.defs#selfLabels',
|
||||||
@@ -225,11 +226,11 @@ async function resolveEmbed(
|
|||||||
draft: PostDraft,
|
draft: PostDraft,
|
||||||
onStateChange: ((state: string) => void) | undefined,
|
onStateChange: ((state: string) => void) | undefined,
|
||||||
): Promise<
|
): Promise<
|
||||||
| AppBskyEmbedImages.Main
|
| $Typed<AppBskyEmbedImages.Main>
|
||||||
| AppBskyEmbedVideo.Main
|
| $Typed<AppBskyEmbedVideo.Main>
|
||||||
| AppBskyEmbedExternal.Main
|
| $Typed<AppBskyEmbedExternal.Main>
|
||||||
| AppBskyEmbedRecord.Main
|
| $Typed<AppBskyEmbedRecord.Main>
|
||||||
| AppBskyEmbedRecordWithMedia.Main
|
| $Typed<AppBskyEmbedRecordWithMedia.Main>
|
||||||
| undefined
|
| undefined
|
||||||
> {
|
> {
|
||||||
if (draft.embed.quote) {
|
if (draft.embed.quote) {
|
||||||
@@ -283,9 +284,9 @@ async function resolveMedia(
|
|||||||
embedDraft: EmbedDraft,
|
embedDraft: EmbedDraft,
|
||||||
onStateChange: ((state: string) => void) | undefined,
|
onStateChange: ((state: string) => void) | undefined,
|
||||||
): Promise<
|
): Promise<
|
||||||
| AppBskyEmbedExternal.Main
|
| $Typed<AppBskyEmbedExternal.Main>
|
||||||
| AppBskyEmbedImages.Main
|
| $Typed<AppBskyEmbedImages.Main>
|
||||||
| AppBskyEmbedVideo.Main
|
| $Typed<AppBskyEmbedVideo.Main>
|
||||||
| undefined
|
| undefined
|
||||||
> {
|
> {
|
||||||
if (embedDraft.media?.type === 'images') {
|
if (embedDraft.media?.type === 'images') {
|
||||||
|
|||||||
Reference in New Issue
Block a user