-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
이미지 다운로드 모바일 기기 대응 #424
이미지 다운로드 모바일 기기 대응 #424
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #424 +/- ##
=======================================
Coverage 91.71% 91.71%
=======================================
Files 44 44
Lines 326 326
Branches 55 55
=======================================
Hits 299 299
Misses 27 27 ☔ View full report in Codecov by Sentry. |
Bundle SizesCompared against 1d81ce0
Dynamic import: No significant changes found |
lgtm |
src/utils/browser.ts
Outdated
// 사용 방법 | ||
// detectMobileDevice(window.navigator.userAgent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 tsdoc으로 써봐도 조흘거가타요~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니당!
src/pages/dna/LoadedDna.tsx
Outdated
// 1. 공유 모드가 가능하다면 공유 모드로 공유 | ||
if (typeof navigator.share !== 'undefined') { | ||
if (await imageShare(imageBase64)) return; | ||
} | ||
|
||
// 2. desktop 이거나 safari이면 다운로드 | ||
if (!detectMobileDevice() || browser === 'Safari') { | ||
imageDownloadPC(imageBase64, 'dna'); | ||
|
||
return; | ||
} | ||
// 3. mobile이면 꾹 눌러서 다운로드 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로직이 간단해 보여서 주석이 없어도 좋을 거 같은데 어떠세요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 그렇다면 주석 제거하겠습니다!
주석 없어도 알아볼수 있다니 성공했다 🚀
src/pages/dna/LoadedDna.tsx
Outdated
if (typeof navigator.share !== 'undefined') { | ||
if (await imageShare(imageBase64)) return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (typeof navigator.share !== 'undefined') { | |
if (await imageShare(imageBase64)) return; | |
} | |
if (typeof navigator.share !== 'undefined') { | |
await imageShare(imageBase64) | |
return; | |
} |
이렇게 해도 되는 거 같은데, 표현식을 if 문으로 감싸주신 이유가 있으신가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageShare 함수를 확인해보면 리턴값이 boolean인데, 혹시 실패하는 상황에는 return 하지 않음으로써
후순위에 있는 이미지 다운 기능을 실행하기 위해 이렇게 작성하였습니다!
더 좋은 방향을 아신다면 알려주세요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호 이미지 쉐어가 실패할 수도 있군뇨 몰랐어용 👍 👍
const isImageShared = await imageShare(imageBase64);
if (isImageShare) return;
이렇게 풀어 쓸 수도 있을 거 같은데, 지금도 좋아 보입니다 ~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니당~
🤔 해결하려는 문제가 무엇인가요?
아이폰 사파리 외에 다른 모바일에서 이미지 다운로드가 되지 않는 문제가 있었어요
🎉 변경 사항
navigator.share
기능이 지원되는 디바이스라면, 공유를 하도록 하고,a
태그를 이용해 다운 받을 수 있도록 하였습니다.