* Increase network timeouts (close #248) * Fix: on post error only update the ext link card if it's in use
This commit is contained in:
parent
06e09facfe
commit
ea4ec26683
2 changed files with 13 additions and 7 deletions
|
@ -1,7 +1,8 @@
|
||||||
import AtpAgent from '@atproto/api'
|
import AtpAgent from '@atproto/api'
|
||||||
import RNFS from 'react-native-fs'
|
import RNFS from 'react-native-fs'
|
||||||
|
|
||||||
const TIMEOUT = 10e3 // 10s
|
const GET_TIMEOUT = 15e3 // 15s
|
||||||
|
const POST_TIMEOUT = 60e3 // 60s
|
||||||
|
|
||||||
export function doPolyfill() {
|
export function doPolyfill() {
|
||||||
AtpAgent.configure({fetch: fetchHandler})
|
AtpAgent.configure({fetch: fetchHandler})
|
||||||
|
@ -43,7 +44,10 @@ async function fetchHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
const controller = new AbortController()
|
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, {
|
const res = await fetch(reqUri, {
|
||||||
method: reqMethod,
|
method: reqMethod,
|
||||||
|
|
|
@ -293,11 +293,13 @@ export const ComposePost = observer(function ComposePost({
|
||||||
imageCount: selectedPhotos.length,
|
imageCount: selectedPhotos.length,
|
||||||
})
|
})
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setExtLink({
|
if (extLink) {
|
||||||
...extLink,
|
setExtLink({
|
||||||
isLoading: true,
|
...extLink,
|
||||||
localThumb: undefined,
|
isLoading: true,
|
||||||
} as apilib.ExternalEmbedDraft)
|
localThumb: undefined,
|
||||||
|
} as apilib.ExternalEmbedDraft)
|
||||||
|
}
|
||||||
setError(cleanError(e.message))
|
setError(cleanError(e.message))
|
||||||
setIsProcessing(false)
|
setIsProcessing(false)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue