Skip to content

Commit

Permalink
fix: allow translation view to load
Browse files Browse the repository at this point in the history
  • Loading branch information
cngonzalez committed Jul 31, 2023
1 parent 789f095 commit b889e76
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanity-translations-tab",
"version": "4.0.0-beta",
"version": "4.0.1-beta",
"description": "This is the base module for implementing common translation vendor tasks from a Studio, such as sending content to be translated in some specific languages, importing content back etc. Not useful on its own, but vendor-specific plugins will use this for its chrome.",
"keywords": [
"sanity",
Expand Down
39 changes: 18 additions & 21 deletions src/components/TranslationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,26 @@ export const TranslationView = () => {
}

const {adapter, secrets, documentId} = context
const shouldFetch = adapter && secrets && documentId && !task
if (shouldFetch) {
adapter
.getLocales(secrets)
.then(setLocales)
.then(() => adapter.getTranslationTask(documentId, secrets))
.then(setTask)
.catch((err) => {
let errorMsg
if (err instanceof Error) {
errorMsg = err.message
} else {
errorMsg = err ? String(err) : null
}
adapter
.getLocales(secrets)
.then(setLocales)
.then(() => adapter.getTranslationTask(documentId, secrets))
.then(setTask)
.catch((err) => {
let errorMsg
if (err instanceof Error) {
errorMsg = err.message
} else {
errorMsg = err ? String(err) : null
}

toast.push({
title: `Error fetching translation job`,
description: errorMsg,
status: 'error',
closable: true,
})
toast.push({
title: `Error fetching translation job`,
description: errorMsg,
status: 'error',
closable: true,
})
}
})
}

fetchData()
Expand Down

0 comments on commit b889e76

Please sign in to comment.