Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

fix: type thumbnail callback (#6024)

authored by yoginth.com and committed by

GitHub 2542d829 78a06f3b

+5 -8
+1 -4
apps/web/src/components/Composer/ChooseThumbnail.tsx
··· 49 49 getFileFromDataURL( 50 50 thumbnails[index].blobUrl, 51 51 "thumbnail.jpeg", 52 - async (file: any) => { 53 - if (!file) { 54 - return toast.error("Please upload a custom thumbnail"); 55 - } 52 + async (file: File) => { 56 53 const result = await uploadThumbnailToStorageNode(file); 57 54 setThumbnails( 58 55 thumbnails.map((thumbnail, i) => {
+2 -2
apps/web/src/helpers/getFileFromDataURL.test.ts
··· 56 56 createElementSpy.mockRestore(); 57 57 }); 58 58 59 - it("returns null when image fails to load", async () => { 59 + it("does nothing when image fails to load", async () => { 60 60 class ErrorImage extends TestImage { 61 61 set src(_url: string) { 62 62 queueMicrotask(() => this.onerror?.()); ··· 71 71 72 72 await Promise.resolve(); 73 73 74 - expect(callback).toHaveBeenCalledWith(null); 74 + expect(callback).not.toHaveBeenCalled(); 75 75 }); 76 76 });
+2 -2
apps/web/src/helpers/getFileFromDataURL.ts
··· 1 1 const getFileFromDataURL = ( 2 2 dataUrl: string, 3 3 fileName: string, 4 - callback: (file: File | null) => void 4 + callback: (file: File) => void 5 5 ) => { 6 6 const img = new Image(); 7 7 img.crossOrigin = "Anonymous"; ··· 22 22 }); 23 23 }; 24 24 img.onerror = () => { 25 - callback(null); 25 + // Ignore errors 26 26 }; 27 27 }; 28 28