Skip to content
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

Merged
merged 8 commits into from Jan 15, 2024

Conversation

sumi-0011
Copy link
Member

🤔 해결하려는 문제가 무엇인가요?

스톱워치 페이지에서 예상치 못하게 종료되는 경우, 홈화면을 접근했을 경우 다시 스톱워치 페이지로 이동할 수 있는 스낵바를 띄웠어요.
그리고 이동하면 스토리지에 저장된 시간 값으로 시간을 초기화 해주었습니다.
또한, 뒤로가기 버튼을 클릭한 경우에는 스토리지를 초기화 하였습니다.

스크린샷 2024-01-14 오후 11 04 21

🙏 여기는 꼭 봐주세요!

  • 스토리지를 접근하는 시간동안은 시작 버튼을 비활성화 하도록 수정하였어요.
  • @wade3420 이전에 이야기했듯이, 스낵바의 버튼을 클릭하거나 / 페이지가 이동되면 스낵바를 화면에서 없앨 수 있는 기능이 필요해요.
  • 이후에 회원 / 미션 리스트 등이 안정화 되면, 오늘 날짜의 기록인지도 확인하는 로직을 넣을 예정이예요

@sumi-0011 sumi-0011 added the enhancement New feature or request label Jan 14, 2024
@sumi-0011 sumi-0011 added this to the 2차 MVP milestone Jan 14, 2024
@sumi-0011 sumi-0011 self-assigned this Jan 14, 2024
Copy link

vercel bot commented Jan 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
10mm-client-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2024 3:53pm

Copy link
Contributor


useEffect(() => {
checkLeaveMission();
console.log('useLeaveMissionCheck: ', useLeaveMissionCheck);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 친구 테스트용이라면 제거되어도 될것 같은데 맞게 이해한 것일지 궁금하빈다~

Copy link
Member Author

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pooling을 위한 시간으로 이해했는데 맞을까요?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 맞아요 라이브로 갈때는 DEFAULT_MS로 가게될 텐데, env에 추가하는 방법도 괜찮을 것 같네요

Copy link
Member Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initSeconds가 NaN으로 나오거나 0으로 나오면 실행이 안될걸로 이해했는데 다르게 이해한 것일지, 의도된 것일지 궁금해요!

Copy link
Member Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중도 재시작시에는 로그만 쏜다 가 쉽게 이해가 안가서 궁금해요!

Copy link
Member Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아래 주석의 내용중 카운터 속도가 증가 되는 경우는 어떤경우 인가요?!

Copy link
Member Author

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]); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의존성 배열에 onVisibilityChange 값이 들어가게된 이유가 궁금해요

Copy link
Member Author

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만이 저장되게 됩니다.

이러한 이유로 의존성 배열에 추가하였어요

@sumi-0011 sumi-0011 merged commit a35b966 into develop Jan 15, 2024
3 checks passed
@sumi-0011 sumi-0011 deleted the feat/home-timer-move branch January 15, 2024 16:08
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 스톱워치 화면에서 이탈 후 홈탭 접근시 타이머 페이지로 랜딩
2 participants