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
[Feat] 예외 케이스 : 타이머 상세 페이지 [미션 중일 때 앱을 껐다 킬 경우] 대응 #297
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
useEffect(() => { | ||
checkLeaveMission(); | ||
console.log('useLeaveMissionCheck: ', useLeaveMissionCheck); |
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.
음 아직은 있는게 좋을 것 같아요!
일단 잘 되는지 확인 테스트는, 나중에나 가능할 것 같아서요!
@@ -7,13 +8,12 @@ const INIT_SECONDS = 0; | |||
const MAX_SECONDS = 60 * 60; // max 1 hour | |||
|
|||
const DEFAULT_MS = 1000; | |||
const TEST_MS = 1; | |||
const TEST_MS = 50; |
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.
pooling을 위한 시간으로 이해했는데 맞을까요?!
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.
넵 맞아요 라이브로 갈때는 DEFAULT_MS
로 가게될 텐데, env에 추가하는 방법도 괜찮을 것 같네요
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.
#308
이슈 열었습니다! 후에 추가할게요~
// init time setting | ||
const initSecondString = localStorage.getItem(STORAGE_KEY.STOPWATCH.TIME); | ||
const initSeconds = Number(initSecondString); | ||
if (initSeconds && initSeconds < MAX_SECONDS) { |
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.
initSeconds가 NaN으로 나오거나 0으로 나오면 실행이 안될걸로 이해했는데 다르게 이해한 것일지, 의도된 것일지 궁금해요!
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.
넵 맞습니다 실행이 되지 않으면 second가 초기값 0으로 유지되기 때문에 문제 없습니당
onNextStep('progress'); | ||
// 중도 재시작 | ||
if (time > 0) { | ||
eventLogger.logEvent(EVENT_LOG_NAME.STOPWATCH.CLICK_RESTART, EVENT_LOG_CATEGORY.STOPWATCH); |
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.
위에 시작하는 로직인 onNextStep('progress');
있습니다!
중도 시작이 아닌, 시작의 경우에는 밑과 같은 플로우가 실행됩니다
- 시작 로그를 쏘고
- 시작한 미션의 id를 스토리지에 저장하고,
- 미션 시작 시간을 스토리지에 저장
document.addEventListener('visibilitychange', onVisibilityChange); | ||
|
||
// 컴포넌트가 언마운트될 때 이벤트 리스너를 제거합니다. | ||
return () => { | ||
document.removeEventListener('visibilitychange', onVisibilityChange); | ||
}; | ||
}, []); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다. | ||
}, [onVisibilityChange]); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다. | ||
} | ||
|
||
export function useRecordMidTime(time: number) { |
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.
잘못된 주석입니다 제거할게용ㅎㅎ..
document.addEventListener('visibilitychange', onVisibilityChange); | ||
|
||
// 컴포넌트가 언마운트될 때 이벤트 리스너를 제거합니다. | ||
return () => { | ||
document.removeEventListener('visibilitychange', onVisibilityChange); | ||
}; | ||
}, []); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다. | ||
}, [onVisibilityChange]); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다. |
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.
의존성 배열에 onVisibilityChange 값이 들어가게된 이유가 궁금해요
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.
들어가지 않는다면,
좀 복잡하지만 😅 메소드 호출을 따라 뭘 부르는지 확인해보면 onVisibilityChange > onAction > onSaveTime
인데,
여기 onSaveTime
부분에서 time
을 저장하게 되는데, 이때 onVisibilityChange
를 의존성 배열에 추가하지 않는다면 time
이 초기 시점인 0
으로 고정되어 time이 계속 0이고, 스토리지에는 계속 0만이 저장되게 됩니다.
이러한 이유로 의존성 배열에 추가하였어요
🤔 해결하려는 문제가 무엇인가요?
스톱워치 페이지에서 예상치 못하게 종료되는 경우, 홈화면을 접근했을 경우 다시 스톱워치 페이지로 이동할 수 있는 스낵바를 띄웠어요.
그리고 이동하면 스토리지에 저장된 시간 값으로 시간을 초기화 해주었습니다.
또한, 뒤로가기 버튼을 클릭한 경우에는 스토리지를 초기화 하였습니다.
🙏 여기는 꼭 봐주세요!