Add some comments
This commit is contained in:
@@ -199,6 +199,9 @@ export function Provider({children}: React.PropsWithChildren<unknown>) {
|
|||||||
await googleTranslate(text, targetLangCode, sourceLangCode)
|
await googleTranslate(text, targetLangCode, sourceLangCode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delay the translation until the animation completes for cases where the
|
||||||
|
// `attemptTranslation` call resolves very quickly.
|
||||||
const translateAfterAnimation = async () => {
|
const translateAfterAnimation = async () => {
|
||||||
try {
|
try {
|
||||||
const result = await attemptTranslation(
|
const result = await attemptTranslation(
|
||||||
@@ -240,6 +243,8 @@ export function Provider({children}: React.PropsWithChildren<unknown>) {
|
|||||||
await googleTranslate(text, targetLangCode, sourceLangCode)
|
await googleTranslate(text, targetLangCode, sourceLangCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Translate after the next state change.
|
||||||
LayoutAnimation.configureNext(
|
LayoutAnimation.configureNext(
|
||||||
LayoutAnimation.Presets.easeInEaseOut,
|
LayoutAnimation.Presets.easeInEaseOut,
|
||||||
() => void translateAfterAnimation(),
|
() => void translateAfterAnimation(),
|
||||||
|
|||||||
Reference in New Issue
Block a user