[Glitch] Gradually increase retry waiting for media processing
Port bc7a8ae6d6
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
parent
b61c3ddff8
commit
474cd302c9
|
@ -286,12 +286,15 @@ export function uploadCompose(files) {
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
dispatch(uploadComposeSuccess(data, f));
|
dispatch(uploadComposeSuccess(data, f));
|
||||||
} else if (status === 202) {
|
} else if (status === 202) {
|
||||||
|
let tryCount = 1;
|
||||||
const poll = () => {
|
const poll = () => {
|
||||||
api(getState).get(`/api/v1/media/${data.id}`).then(response => {
|
api(getState).get(`/api/v1/media/${data.id}`).then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
dispatch(uploadComposeSuccess(response.data, f));
|
dispatch(uploadComposeSuccess(response.data, f));
|
||||||
} else if (response.status === 206) {
|
} else if (response.status === 206) {
|
||||||
setTimeout(() => poll(), 1000);
|
let retryAfter = (Math.log2(tryCount) || 1) * 1000;
|
||||||
|
tryCount += 1;
|
||||||
|
setTimeout(() => poll(), retryAfter);
|
||||||
}
|
}
|
||||||
}).catch(error => dispatch(uploadComposeFail(error)));
|
}).catch(error => dispatch(uploadComposeFail(error)));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue