about summary refs log tree commit diff
path: root/app/javascript/flavours
diff options
context:
space:
mode:
authorJeong Arm <kjwonmail@gmail.com>2022-01-10 22:25:08 +0900
committerClaire <claire.github-309c@sitedethib.com>2022-01-16 18:14:33 +0100
commit474cd302c91204fb05b2824ea17e3197e76032c7 (patch)
tree6316b8527e8dec162833f7dda34466d0f0d82ed1 /app/javascript/flavours
parentb61c3ddff8338432fdc287f6bebbf76a12859c17 (diff)
[Glitch] Gradually increase retry waiting for media processing
Port bc7a8ae6d6d2c2118e5c49add83539498b9d543b to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r--app/javascript/flavours/glitch/actions/compose.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js
index 9af8b6d20..261c72b2a 100644
--- a/app/javascript/flavours/glitch/actions/compose.js
+++ b/app/javascript/flavours/glitch/actions/compose.js
@@ -286,12 +286,15 @@ export function uploadCompose(files) {
           if (status === 200) {
             dispatch(uploadComposeSuccess(data, f));
           } else if (status === 202) {
+            let tryCount = 1;
             const poll = () => {
               api(getState).get(`/api/v1/media/${data.id}`).then(response => {
                 if (response.status === 200) {
                   dispatch(uploadComposeSuccess(response.data, f));
                 } 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)));
             };