Skip to content

Commit

Permalink
Add window reload to startOver() function
Browse files Browse the repository at this point in the history
This removes the need for the repeated calls to `generateImage()` when
profile pictures are downloaded.
  • Loading branch information
kohrVid committed Jan 29, 2024
1 parent c2510a0 commit 03379fc
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,17 @@ export default function Home() {
} catch (error) {
console.log("Error generating image", error)
}
}
};

const handleDownload = async () => {
// TODO: Fix if possible. This is a hack to ensure that image generated is as expected. Without repeating generateImage(), at times, the image wont be generated correctly.
await generateImage()
await generateImage()
await generateImage()
const generatedImageUrl = await generateImage()
if (generatedImageUrl) {
download(generatedImageUrl, `profile-pic-${filePostfix}.png`)
}
};
}

const startOver = async () => {
setUserImageUrl(undefined);
const startOver = () => {
window.location.reload();
};

return (
Expand Down

0 comments on commit 03379fc

Please sign in to comment.