Live video on the AT Protocol
79
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #231 from streamplace/natb/upload-thrice

fix: retry logic if the thumbnail doesn't upload right

authored by

Eli Mallon and committed by
GitHub
55027bab 54479f6d

+22 -1
+22 -1
js/app/features/bluesky/blueskySlice.tsx
··· 75 75 customThumbnail?: Blob, 76 76 ) => { 77 77 if (customThumbnail) { 78 + let tries = 0; 78 79 try { 79 - const thumbnail = await pdsAgent.uploadBlob(customThumbnail); 80 + let thumbnail = await pdsAgent.uploadBlob(customThumbnail); 81 + 82 + while ( 83 + thumbnail.data.blob.size === 0 && 84 + customThumbnail.size !== 0 && 85 + tries < 3 86 + ) { 87 + console.warn( 88 + "Reuploading blob as blob sizes don't match! Blob size recieved is", 89 + thumbnail.data.blob.size, 90 + "and sent blob size is", 91 + customThumbnail.size, 92 + ); 93 + thumbnail = await pdsAgent.uploadBlob(customThumbnail); 94 + } 95 + 96 + if (tries === 3) { 97 + throw new Error("Could not successfully upload blob (tried thrice)"); 98 + } 99 + 80 100 if (thumbnail.success) { 81 101 console.log("Successfully uploaded thumbnail"); 82 102 return thumbnail.data.blob; ··· 497 517 ); 498 518 } 499 519 const thumbnailBlob = await thumbnailRes.blob(); 520 + console.log(thumbnailBlob); 500 521 thumbnail = await uploadThumbnail( 501 522 profile.handle, 502 523 u,