Increase network timeouts (closes #248) (#249)

* Increase network timeouts (close #248)

* Fix: on post error only update the ext link card if it's in use
zio/stable
Paul Frazee 2023-03-02 13:31:16 -06:00 committed by GitHub
parent 06e09facfe
commit ea4ec26683
2 changed files with 13 additions and 7 deletions

View File

@ -1,7 +1,8 @@
import AtpAgent from '@atproto/api'
import RNFS from 'react-native-fs'
const TIMEOUT = 10e3 // 10s
const GET_TIMEOUT = 15e3 // 15s
const POST_TIMEOUT = 60e3 // 60s
export function doPolyfill() {
AtpAgent.configure({fetch: fetchHandler})
@ -43,7 +44,10 @@ async function fetchHandler(
}
const controller = new AbortController()
const to = setTimeout(() => controller.abort(), TIMEOUT)
const to = setTimeout(
() => controller.abort(),
reqMethod === 'post' ? POST_TIMEOUT : GET_TIMEOUT,
)
const res = await fetch(reqUri, {
method: reqMethod,

View File

@ -293,11 +293,13 @@ export const ComposePost = observer(function ComposePost({
imageCount: selectedPhotos.length,
})
} catch (e: any) {
setExtLink({
...extLink,
isLoading: true,
localThumb: undefined,
} as apilib.ExternalEmbedDraft)
if (extLink) {
setExtLink({
...extLink,
isLoading: true,
localThumb: undefined,
} as apilib.ExternalEmbedDraft)
}
setError(cleanError(e.message))
setIsProcessing(false)
return