diff options
author | Matthieu Sieben <matthieusieben@users.noreply.github.com> | 2024-05-12 23:18:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-12 14:18:42 -0700 |
commit | 00a57df5b16bc946c50079914962cc2819011e80 (patch) | |
tree | 4040fad00e74757d846bc503147b9e601e443c84 /src/lib/api | |
parent | 4458b031732149d6f9c107582b9e4ec343385518 (diff) | |
download | voidsky-00a57df5b16bc946c50079914962cc2819011e80.tar.zst |
✅ Fix "Download CAR file" on mobile (#3816)
* download CAR file using AtpAgent instead of building URL * add loader icon on download car button * actually save to disk on android * style nits * bottom margin nit * localize toast * remove fallback so back button works correctly * keep throwing an error if mime type isn't used * be more explicit with toasts * send errors to sentry when encountered --------- Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/lib/api')
-rw-r--r-- | src/lib/api/api-polyfill.ts | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/api/api-polyfill.ts b/src/lib/api/api-polyfill.ts index ea1d97598..e3aec7631 100644 --- a/src/lib/api/api-polyfill.ts +++ b/src/lib/api/api-polyfill.ts @@ -1,5 +1,5 @@ -import {BskyAgent, stringifyLex, jsonToLex} from '@atproto/api' import RNFS from 'react-native-fs' +import {BskyAgent, jsonToLex, stringifyLex} from '@atproto/api' const GET_TIMEOUT = 15e3 // 15s const POST_TIMEOUT = 60e3 // 60s @@ -68,8 +68,10 @@ async function fetchHandler( resBody = jsonToLex(await res.json()) } else if (resMimeType.startsWith('text/')) { resBody = await res.text() + } else if (resMimeType === 'application/vnd.ipld.car') { + resBody = await res.arrayBuffer() } else { - throw new Error('TODO: non-textual response body') + throw new Error('Non-supported mime type') } } |