-
Notifications
You must be signed in to change notification settings - Fork 7
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: 새로운 메시지 저장 시 refetch 전까지 이전 메시지들을 보여주는 오류를 해결 #498
base: develop
Are you sure you want to change the base?
Changes from 4 commits
569bd30
9866d7b
b8bc69d
9a693fd
e835b8d
c0c8250
3872f8e
39808d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
import React, { useState } from "react"; | ||
|
||
import { ValueOf } from "@/types"; | ||
import { ROLLINGPAPER_STATE_TYPE } from "@/constants"; | ||
|
||
const useMessageWrite = () => { | ||
const [isWrite, setIsWrite] = useState(false); | ||
const [rollingpaperState, setRollingpaperState] = useState< | ||
ValueOf<typeof ROLLINGPAPER_STATE_TYPE> | ||
>(ROLLINGPAPER_STATE_TYPE.NORMAL); | ||
|
||
const handleWriteButtonClick = () => { | ||
setIsWrite(true); | ||
setRollingpaperState(ROLLINGPAPER_STATE_TYPE.WRITE); | ||
}; | ||
|
||
const handleEditButtonClick = () => { | ||
setRollingpaperState(ROLLINGPAPER_STATE_TYPE.EDIT); | ||
}; | ||
|
||
const handleWriteEnd = () => { | ||
setIsWrite(false); | ||
setRollingpaperState(ROLLINGPAPER_STATE_TYPE.NORMAL); | ||
}; | ||
|
||
return { isWrite, handleWriteButtonClick, handleWriteEnd }; | ||
return { | ||
rollingpaperState, | ||
handleWriteButtonClick, | ||
handleEditButtonClick, | ||
handleWriteEnd, | ||
}; | ||
}; | ||
|
||
export default useMessageWrite; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,22 @@ import LetterPaper from "@/pages/RollingpaperPage/components/LetterPaper"; | |
|
||
import useValidatedParam from "@/hooks/useValidatedParam"; | ||
import { useReadRollingpaper } from "@/pages/RollingpaperPage/hooks/useReadRollingpaper"; | ||
import useMessageWrite from "./hooks/useMessageWrite"; | ||
|
||
const RollingpaperPage = () => { | ||
const teamId = useValidatedParam<number>("teamId"); | ||
const rollingpaperId = useValidatedParam<number>("rollingpaperId"); | ||
const { | ||
rollingpaperState, | ||
handleWriteButtonClick, | ||
handleWriteEnd, | ||
handleEditButtonClick, | ||
} = useMessageWrite(); | ||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 친구는 LetterPaper 내로 들어가도 되겠네요. 꼭 RollinpaperPage에 있어야 할 이유가 없는 것 같은데, 한번 확인해주세요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. handleWriteEnd 때문에 상단에서 다 관리하자! 라는 생각으로 구현한 것 같아요. 이 훅도 그렇고 전반적으로 LetterPaper 컴포넌트를 따로 두는 것보다 index 내부에서 전부 처리해주는 것이 prop drilling도 적게 일어나고 코드를 알아보기 좋을 것 같은데... 어떻게하면 하나의 컴포넌트에 다 데려올 수 있을지 고민해봐야겠어요 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그럼 일단은 index.tsx에서 useMessageWrite를 사용하는 방식을 유지하는 걸까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네네 이거를 옮길려고 하니까 복잡해지는 것 같더라고요. 밑에 코멘트 준 대로 context를 도입해야하나 생각이 들기도 하고 구조를 좀 바꾸면서 위치도 옮겨주는게 좋을 것 같아요! |
||
|
||
const { isLoading, data: rollingpaper } = useReadRollingpaper({ | ||
teamId, | ||
rollingpaperId, | ||
handleWriteEnd, | ||
}); | ||
|
||
if (isLoading) { | ||
|
@@ -26,9 +34,13 @@ const RollingpaperPage = () => { | |
<PageTitleWithBackButton>{rollingpaper.title}</PageTitleWithBackButton> | ||
<main> | ||
<LetterPaper | ||
rollingpaperState={rollingpaperState} | ||
to={rollingpaper.to} | ||
recipientType={rollingpaper.recipient} | ||
messageList={[...rollingpaper.messages]} | ||
handleWriteButtonClick={handleWriteButtonClick} | ||
handleEditButtonClick={handleEditButtonClick} | ||
handleWriteEnd={handleWriteEnd} | ||
/> | ||
</main> | ||
</> | ||
|
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.
얘 이름이 useMessage네요. useMessageBox로 변경해야겠습니다.
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.
놓치고 있었는데 굿굿굿 e835b8d