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

[Feature] Study status changing in real time #10

Merged

Conversation

saseungmin
Copy link
Collaborator

@saseungmin saseungmin commented Nov 20, 2020

🚀 구현 목록

  • 스터디 목록의 상태가 실시간으로 변경된다. (목록은 모집중, 모집마감)
  • interval를 사용해야 하기 때문에 커스텀 useInterval를 사용한다.
    리액트 Hooks에서 setInterval을 사용하면 문제가 발생. (제대로 실행이 안됨.)

real_time_change

🤔 추가적으로 진행할 사항들

  • useInterval의 테스트를 작성하는 법.. coverage가 100%가 안된다. 😢
    아니면 이미 구현되어 있는 커스텀 훅을 npm으로 install을 할것인가.(use-interval)
    코드를 보니 구현한 방식랑 거의 같음.

- Study status changing in real time
- npm install moment.js and react-moment
@@ -11,12 +11,13 @@ const StudyGroupsWrapper = styled.div`
align-content: space-between;
`;

const StudyGroups = ({ groups }) => (
const StudyGroups = ({ groups, seconds }) => (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

seconds props를 삭제해주자. 필요없다.

<StudyGroupsWrapper>
{groups.map((group) => (
<StudyGroup
key={group.id}
group={group}
seconds={seconds}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

여기도.

Comment on lines +17 to +19
useInterval(() => {
setRealTime(Date.now());
}, 1000);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • useInterval에 대한 테스트를 어떻게 작성해야할까..🤔 (coverage 실패)


useEffect(() => {
function tick() {
savedCallback.current();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • 여기도 coverage fail

@saseungmin saseungmin added the enhancement New feature or request label Nov 20, 2020
}, 1000);

const isCheckedTimeStatus = () => {
if (realTime - applyEndTime >= 0 || participants.length === personnel) {

Choose a reason for hiding this comment

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

시간이 초과하거나, 참여자의 수가 초과할 경우 마감이라고 표시해주는 것 같아요. 함수로 분리해주는건 어떨까요?

setRealTime(Date.now());
}, 1000);

const isCheckedTimeStatus = () => {

Choose a reason for hiding this comment

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

isCheckedTimeStatus는 true 혹은 false만 반환할 것 같은데 실제로는 컴포넌트를 반환하고 있네요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

처음에 true false로 반환할려구 했던 함수였는데 컴포넌트로 반환하는걸로 변경 후 함수 이름을 변경하지 못했줬네요..

@saseungmin saseungmin merged commit acbb9e0 into CodeSoom:main Nov 20, 2020
@saseungmin saseungmin mentioned this pull request Nov 20, 2020
11 tasks
@saseungmin saseungmin deleted the real-time-change-study-recruit-status branch July 5, 2021 19:54
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.

None yet

2 participants