Skip to content

Commit

Permalink
Move function
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Oct 6, 2024
1 parent 9aca51c commit fb9c9e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 13 additions & 1 deletion src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
BlobRef,
BskyAgent,
ComAtprotoLabelDefs,
ComAtprotoRepoStrongRef,
RichText,
} from '@atproto/api'

Expand All @@ -26,7 +27,7 @@ import {
import {ComposerState, EmbedDraft} from '#/view/com/composer/state/composer'
import {createGIFDescription} from '../gif-alt-text'
import {LinkMeta} from '../link-meta/link-meta'
import {resolveGif, resolveLink, resolveRecord} from './resolve'
import {resolveGif, resolveLink} from './resolve'
import {uploadBlob} from './upload-blob'

export {uploadBlob}
Expand Down Expand Up @@ -326,3 +327,14 @@ async function resolveMedia(
}
return undefined
}

async function resolveRecord(
agent: BskyAgent,
uri: string,
): Promise<ComAtprotoRepoStrongRef.Main> {
const resolvedLink = await resolveLink(agent, uri)
if (resolvedLink.type !== 'record') {
throw Error('Expected uri to resolve to a record')
}
return resolvedLink.record
}
11 changes: 0 additions & 11 deletions src/lib/api/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ type ResolvedRecord = {

type ResolvedLink = ResolvedExternalLink | ResolvedRecord

export async function resolveRecord(
agent: BskyAgent,
uri: string,
): Promise<ComAtprotoRepoStrongRef.Main> {
const resolvedLink = await resolveLink(agent, uri)
if (resolvedLink.type !== 'record') {
throw Error('Expected uri to resolve to a record')
}
return resolvedLink.record
}

export async function resolveLink(
agent: BskyAgent,
uri: string,
Expand Down

0 comments on commit fb9c9e4

Please sign in to comment.