Skip to content

Commit

Permalink
Merge pull request #29 from UmairJibran/main
Browse files Browse the repository at this point in the history
add postfix to image generated
  • Loading branch information
janajri authored Jan 23, 2024
2 parents 3c00e21 + 335d359 commit c2510a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function Home() {
const [unsuportedBrowser, setUnsupportedBrowser] = useState(false);
const [loader, setLoader] = useState(false)
const [gazaStatusSummary, setGazaStatusSummary] = useState()
const [filePostfix, setFilePostfix] = useState<SocialPlatform | 'user-upload'>()

useEffect(() => {
const isInstagramBrowser = /Instagram/i.test(navigator.userAgent);
Expand All @@ -31,6 +32,7 @@ export default function Home() {
const reader = new FileReader();

reader.onload = async (event: any) => {
setFilePostfix('user-upload')
setUserImageUrl(event.target.result);
};

Expand All @@ -45,6 +47,7 @@ export default function Home() {
const userProvidedUsername = prompt(`Enter your ${platform} username:`);

if (userProvidedUsername) {
setFilePostfix(platform)
try {
setLoader(true);
const response = await fetch(`/api/retrieve-profile-pic?username=${userProvidedUsername}&platform=${platform}`).then(res => res.ok ? res.json() : null);
Expand Down Expand Up @@ -75,7 +78,7 @@ export default function Home() {
await generateImage()
const generatedImageUrl = await generateImage()
if (generatedImageUrl) {
download(generatedImageUrl, "profile-pic.png")
download(generatedImageUrl, `profile-pic-${filePostfix}.png`)
}
};

Expand Down

0 comments on commit c2510a0

Please sign in to comment.