Translate strings in src/lib/api/index.ts (#5750)
This commit is contained in:
+10
-9
@@ -11,6 +11,7 @@ import {
|
|||||||
ComAtprotoRepoStrongRef,
|
ComAtprotoRepoStrongRef,
|
||||||
RichText,
|
RichText,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {t} from '@lingui/macro'
|
||||||
import {QueryClient} from '@tanstack/react-query'
|
import {QueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {isNetworkError} from '#/lib/strings/errors'
|
import {isNetworkError} from '#/lib/strings/errors'
|
||||||
@@ -52,7 +53,7 @@ export async function post(
|
|||||||
{cleanNewlines: true},
|
{cleanNewlines: true},
|
||||||
)
|
)
|
||||||
|
|
||||||
opts.onStateChange?.('Processing...')
|
opts.onStateChange?.(t`Processing...`)
|
||||||
|
|
||||||
await rt.detectFacets(agent)
|
await rt.detectFacets(agent)
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ export async function post(
|
|||||||
|
|
||||||
let res
|
let res
|
||||||
try {
|
try {
|
||||||
opts.onStateChange?.('Posting...')
|
opts.onStateChange?.(t`Posting...`)
|
||||||
res = await agent.post({
|
res = await agent.post({
|
||||||
text: rt.text,
|
text: rt.text,
|
||||||
facets: rt.facets,
|
facets: rt.facets,
|
||||||
@@ -117,7 +118,7 @@ export async function post(
|
|||||||
})
|
})
|
||||||
if (isNetworkError(e)) {
|
if (isNetworkError(e)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Post failed to upload. Please check your Internet connection and try again.',
|
t`Post failed to upload. Please check your Internet connection and try again.`,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
throw e
|
throw e
|
||||||
@@ -141,7 +142,7 @@ export async function post(
|
|||||||
safeMessage: e.message,
|
safeMessage: e.message,
|
||||||
})
|
})
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Failed to save post interaction settings. Your post was created but users may be able to interact with it.',
|
t`Failed to save post interaction settings. Your post was created but users may be able to interact with it.`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +167,7 @@ export async function post(
|
|||||||
safeMessage: e.message,
|
safeMessage: e.message,
|
||||||
})
|
})
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Failed to save post interaction settings. Your post was created but users may be able to interact with it.',
|
t`Failed to save post interaction settings. Your post was created but users may be able to interact with it.`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,7 +249,7 @@ async function resolveMedia(
|
|||||||
logger.debug(`Uploading images`, {
|
logger.debug(`Uploading images`, {
|
||||||
count: imagesDraft.length,
|
count: imagesDraft.length,
|
||||||
})
|
})
|
||||||
onStateChange?.(`Uploading images...`)
|
onStateChange?.(t`Uploading images...`)
|
||||||
const images: AppBskyEmbedImages.Image[] = await Promise.all(
|
const images: AppBskyEmbedImages.Image[] = await Promise.all(
|
||||||
imagesDraft.map(async (image, i) => {
|
imagesDraft.map(async (image, i) => {
|
||||||
logger.debug(`Compressing image #${i}`)
|
logger.debug(`Compressing image #${i}`)
|
||||||
@@ -302,7 +303,7 @@ async function resolveMedia(
|
|||||||
)
|
)
|
||||||
let blob: BlobRef | undefined
|
let blob: BlobRef | undefined
|
||||||
if (resolvedGif.thumb) {
|
if (resolvedGif.thumb) {
|
||||||
onStateChange?.('Uploading link thumbnail...')
|
onStateChange?.(t`Uploading link thumbnail...`)
|
||||||
const {path, mime} = resolvedGif.thumb.source
|
const {path, mime} = resolvedGif.thumb.source
|
||||||
const response = await uploadBlob(agent, path, mime)
|
const response = await uploadBlob(agent, path, mime)
|
||||||
blob = response.data.blob
|
blob = response.data.blob
|
||||||
@@ -326,7 +327,7 @@ async function resolveMedia(
|
|||||||
if (resolvedLink.type === 'external') {
|
if (resolvedLink.type === 'external') {
|
||||||
let blob: BlobRef | undefined
|
let blob: BlobRef | undefined
|
||||||
if (resolvedLink.thumb) {
|
if (resolvedLink.thumb) {
|
||||||
onStateChange?.('Uploading link thumbnail...')
|
onStateChange?.(t`Uploading link thumbnail...`)
|
||||||
const {path, mime} = resolvedLink.thumb.source
|
const {path, mime} = resolvedLink.thumb.source
|
||||||
const response = await uploadBlob(agent, path, mime)
|
const response = await uploadBlob(agent, path, mime)
|
||||||
blob = response.data.blob
|
blob = response.data.blob
|
||||||
@@ -352,7 +353,7 @@ async function resolveRecord(
|
|||||||
): Promise<ComAtprotoRepoStrongRef.Main> {
|
): Promise<ComAtprotoRepoStrongRef.Main> {
|
||||||
const resolvedLink = await fetchResolveLinkQuery(queryClient, agent, uri)
|
const resolvedLink = await fetchResolveLinkQuery(queryClient, agent, uri)
|
||||||
if (resolvedLink.type !== 'record') {
|
if (resolvedLink.type !== 'record') {
|
||||||
throw Error('Expected uri to resolve to a record')
|
throw Error(t`Expected uri to resolve to a record`)
|
||||||
}
|
}
|
||||||
return resolvedLink.record
|
return resolvedLink.record
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user