-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor/#143 킬링파트 등록 페이지 및 연관 컴포넌트 일괄 리팩토링 #179
Conversation
변수 자체에 시간의 의미를 포함
변수 자체에 시간의 의미를 포함
유튜브 ifram api는 https 요청을 받도록 고정되어있는 api이므로 수정하였음.
1. 컴포넌트 내부 불필요한 player 상태 삭제 2. 사용하지 않는 onStateChange 이벤트 핸들러 삭제 3. 외부에서 player 상태 및 setter 를 전달받도록 개선
VoteInterface 컴포넌트의 각 컴포넌트가 사용할 컨텍스트 생성
컨텍스트에서 제공하는 value에 해당하는 props 제거
1. 컨텍스트 내부에 상태 격리 2. page 단에 존재하기에 어색했던 구간반복 effetct 격리
1. 영상 시작점 props 옵셔널 및 기본값 처리 2. 향후 이벤트 사용 가능성을 고려하여, player set 형식 변경 3. 관련 함수 useCallback 처리
VoteInterface는 특정 컴포넌트 종속적인 provider인것에 비해 VideoPlayer 관련 컴포넌트와 상태는 재사용 할 가능성이 높다고 판단하였음. 이에 따라 provider를 분리하였음.
해당 과정에서 VoteInterfaceContext는 특정 컴포넌트 종속적임을 확정하였음.
interface VoteInterfaceContextProps { | ||
partStartTime: TimeMinSec; | ||
interval: KillingPartInterval; | ||
updatePartStartTime: (timeUnit: string, value: number) => void; |
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.
💬 timeUnit을 union type으로 지정하는 것이 어떤가요?
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.
고생 많으셨어요 또밥. youtube player에 대한 리팩토링은 직접 이야기를 들어서 이해하기 편했습니다. 불필요한 부분 많이 걷어 내고 player 상태도 한 곳에서 관리할 수 있다는 점에서 많이 좋아졌어요. 나머지 부분은 코멘트로 달아놓았습니다.
@@ -5,13 +5,11 @@ declare global { | |||
} | |||
} | |||
|
|||
const PROTOCOL = window.location.protocol === 'http:' ? 'http:' : 'https:'; |
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.
우리 서비스가 https:// 프로토콜을 사용하기 때문에 지우신 것 같은데 맞나요? 아주 그레잇이네요
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.
api자체가 프로토콜 구분이 필요 없더라고요!
https로 리다이렉트 되도록 되어있습니당
그래서 삭제했어요 ~ㅎㅎ
</Share> | ||
</Flex> | ||
</Modal> | ||
<VideoPlayerProvider> |
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.
💬 videoId
를 Provider에서 주입 받아서 contextAPI로 뿌려주는 것은 어떨까요? 현재 코드로는 전역에 player을 하나만 둘 수 있을 것 같아서요. 도밥 의견이 궁금합니다~
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.
같은 고민을 했었습니다 고려해보죠!
|
||
<Modal isOpen={isOpen} closeModal={closeModal}> | ||
<ModalTitle>킬링파트 투표를 완료했습니다.</ModalTitle> | ||
<ModalContent>컨텐츠는 아직 없습니다.</ModalContent> |
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.
같이 의논해서 어떤 메세지를 보내줄지 고민해보면 좋을 것 같네요
<RegisterTitle>당신의 킬링파트에 투표하세요🎧</RegisterTitle> | ||
<KillingPartToggleGroup /> | ||
<IntervalInput | ||
videoLength={videoLength} |
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.
💬 Provider에서 videoLength를 받고 Context로 뿌려주면, videloLength도 props drilling 할 필요 없을 것 같아요. 두밥 생각은 어떠신가요?
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.
이것도 마찬가지로 고민했었어요! 고려해봅시다!
value={{ | ||
partStartTime, | ||
interval, | ||
updatePartStartTime, |
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.
updatePartStartTime 사용처에서 partStartTime의 react 상태를 변경하는 함수라고 계속 염두하고 있어야 할 것 같네요. 보통은 set prefix를 통해 상태를 변경한다고 예측하니까요.
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.
setter 함수를 바로 넘기지 않고 함수로 한번 감싸는 것으로 변동에 용이하게 하려 했어요!
이름은 비슷한 늬양스를 주기위한 단어로 선택했습니다!
|
||
export const ModalContent = styled.p` | ||
font-size: 16px; | ||
color: #b5b3bc; |
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.
💬 모달에 계속 사용할 색이라면 theme에 추가하는 거 어떠신가요?
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.
Context를 활용해서 페이지에서 컴포넌트를 분리하고 관심사를 분리하려고 들어간 노력들이 곳곳에 보이는 것 같아요 👍👍
함께 이야기 나눈 것처럼 작은 단위부터 고쳐나가다보면 만족스러운 리팩토링이 되지 않을까 싶어요!
(여기서는 이만 Approve 하겠습니다! 고생하셨습니다👍👍)
주말 같은날 시간이 괜찮다면 함께 리팩토링 해보는 것도 좋을 것 같네요 😊
}) | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
console.error('[createYoutubePlayer] Youtube Player를 생성하지 못하였습니다.'); | ||
console.error('Youtube Player를 생성하지 못하였습니다.'); |
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.
다시 로드할 수 있는 방식을 제공하면 좋을 것 같네요!
frontend/src/utils/convertTime.ts
Outdated
const timeString = timeSec.toString(); | ||
|
||
if (timeString.length === 1) { | ||
return `0${timeString}`; | ||
} else { | ||
return timeString; | ||
} | ||
}); |
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.
String.prototype.padStart()를 활용하는 것은 어떨까요?
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.
제가 짠 코드 같은데 이게 왜 도밥 PR에 있죠 ㅋㅋㅋ String.prototype.padStart() 를 활용하면 분기처리하지 않아도 되어서 좋겠네요! 굳
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.
시간이 부족해서 먼저 땡겨와서 반영시켰습니다
|
||
useEffect(() => { | ||
const timer = window.setInterval(() => { | ||
const startSecond = minSecToSeconds([partStartTime.minute, partStartTime.second]); |
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.
partStartTime이 객체로 관리될 것이라면, convertTime의 유틸함수도 튜플보다는 객체면 더 편할 것 같네요
const startSecond = minSectoSeconds(partStartTime);
// @/utils/convertTime
const minSectoSeconds = ({ minute, second }: TimeMinSec) => { ... };
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.
추후 시간 단위에 대한 관리를 개편하면서 한번에 수정해봅시다!
<Modal isOpen={isOpen} closeModal={closeModal}> | ||
<ModalTitle>킬링파트 투표를 완료했습니다.</ModalTitle> | ||
<ModalContent> | ||
<Message>{voteTimeText}</Message> | ||
<Message>파트를 공유해 보세요😀</Message> | ||
</ModalContent> | ||
<ButtonContainer> | ||
<Confirm type="button" onClick={closeModal}> | ||
확인 | ||
</Confirm> | ||
<Share | ||
type="button" | ||
onClick={() => copyUrlClipboard(killingPartPostResponse?.partVideoUrl)} | ||
> | ||
공유하기 | ||
</Share> | ||
</ButtonContainer> | ||
</Modal> |
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.
💬 Modal이 VoteInterface의 관심사라고 생각하는 것인지 궁금합니다!
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.
우선 page 단에서 컴포넌트 내부로 옮겨두긴 했습니다만, 코난은 어떻게 생각하시는지용?
기존 유튜브 컴포넌트를 활용한 새로운 page에 context 적용
import 경로 수정
📝작업 내용
💬리뷰 참고사항
작업 내용이 워낙 많아서 리뷰하기 힘드실 것 같습니다.
커밋로그로 리뷰하시면 그나마 수월하실 것 같아요.
혹은 저에게 10분 정도 전체 작업내용 요약해서 설명 들으시면 씽크도 잘 맞고 이해하기 쉬워질 것 같네요.
전체적으로 의도한바는 다음과 같습니다.
TODO 주석 4개 넣어놨어요. 적당히 중요하다고 생각한 부분인데 처리하지 않았습니다.
당장 하지못하는 작업도 있고(API 관련 협의 필요)
무엇보다 페이지 내 로직에 대한 부분은 어느정도 정리가 되었다고 판단했어요.
작업 반경도 이미 충분히 커서 다른 이슈로 작업하는게 좋아보입니다.
#️⃣연관된 이슈
close #143
close #156
close #178