-
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] Board 의 불필요한 재렌더링 줄이기 및 롱폴링 종료 조건 수정 #224
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b12ec9d
chore: BoardState export 하도록 변경
PMtHk e875e29
refactor: 롱폴링 훅의 version 사용방식 변경
PMtHk c0efa52
refactor: /board 라우터의 onLeave 설정 추가
PMtHk f807ae4
fix: boardStore 에서 version 및 setVersion 제거
PMtHk 594dc8f
fix: 보드의 상세 페이지 내 subtask 이벤트 반영
PMtHk 17e5dcf
fix: 상세 페이지 내 label, assignee 의 변경을 보드에도 적용
PMtHk 2acab4a
chore: 라우터의 taskId 를 task 로 수정
PMtHk 4db6c89
fix: long polling 종료 조건 수정
PMtHk 0d0fee9
chore: board 라우트 loader 의 async await 구문 제거
PMtHk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,128 +191,134 @@ export function KanbanBoard({ projectId }: KanbanBoardProps) { | |
}; | ||
|
||
return ( | ||
<div className="spazce-x-2 flex h-[calc(100vh-110px)] gap-2 overflow-x-auto p-4"> | ||
<AnimatePresence mode="popLayout"> | ||
{sections.map((section) => ( | ||
<Section | ||
key={section.id} | ||
className={cn( | ||
'flex h-full w-[352px] flex-shrink-0 flex-col items-center', | ||
'bg-transparent', | ||
section.id === belowSectionId && belowTaskId === -1 && 'border-2 border-blue-400' | ||
)} | ||
> | ||
<SectionHeader className="flex w-full items-center justify-between gap-2 space-y-0"> | ||
<div className="flex items-center gap-2"> | ||
<SectionTitle className="text-xl">{section.name}</SectionTitle> | ||
<SectionCount>{section.tasks.length}</SectionCount> | ||
</div> | ||
<SectionDropdownMenu> | ||
<div className="relative h-full overflow-hidden"> | ||
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. 외부에 있던 스타일을 위한 |
||
<div className="spazce-x-2 flex h-[calc(100vh-110px)] gap-2 overflow-x-auto p-4"> | ||
<AnimatePresence mode="popLayout"> | ||
{sections.map((section) => ( | ||
<Section | ||
key={section.id} | ||
className={cn( | ||
'flex h-full w-[352px] flex-shrink-0 flex-col items-center', | ||
'bg-transparent', | ||
section.id === belowSectionId && belowTaskId === -1 && 'border-2 border-blue-400' | ||
)} | ||
> | ||
<SectionHeader className="flex w-full items-center justify-between gap-2 space-y-0"> | ||
<div className="flex items-center gap-2"> | ||
<SectionTitle className="text-xl">{section.name}</SectionTitle> | ||
<SectionCount>{section.tasks.length}</SectionCount> | ||
</div> | ||
<SectionDropdownMenu> | ||
<Button | ||
type="button" | ||
variant="ghost" | ||
className="text-blac hover:text-primary w-full border-none px-0 hover:bg-white" | ||
onClick={() => handleCreateTask(section.id)} | ||
> | ||
<PlusIcon /> | ||
Add Task | ||
</Button> | ||
</SectionDropdownMenu> | ||
</SectionHeader> | ||
<SectionContent | ||
key={section.id} | ||
className="flex w-full flex-1 flex-col items-center gap-2 overflow-y-auto pt-1" | ||
onDragOver={(e) => handleDragOver(e, section.id)} | ||
onDragLeave={handleDragLeave} | ||
onDrop={(e) => handleDrop(e, section.id)} | ||
onDragEnd={handleDragEnd} | ||
> | ||
{section.tasks.map((task) => ( | ||
<motion.div | ||
key={task.id} | ||
layout | ||
layoutId={task.id.toString()} | ||
draggable | ||
initial={{ opacity: 1, zIndex: 1 }} | ||
animate={{ | ||
zIndex: task.id === belowTaskId ? 50 : 1, | ||
scale: task.id === belowTaskId ? 1.02 : 1, | ||
}} | ||
transition={{ | ||
layout: { duration: 0.3 }, | ||
scale: { duration: 0.2 }, | ||
}} | ||
style={{ position: 'relative' }} | ||
onDragStart={(e) => | ||
handleDragStart( | ||
e as unknown as DragEvent<HTMLDivElement>, | ||
section.id, | ||
task.id | ||
) | ||
} | ||
onDrop={(e) => handleDrop(e, section.id)} | ||
onDragOver={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
handleDragOver(e, section.id, task.id); | ||
}} | ||
onDragLeave={handleDragLeave} | ||
> | ||
<Card | ||
className={cn( | ||
'w-56 border bg-white transition-all duration-300 md:w-80', | ||
task.id === belowTaskId && 'border-2 border-blue-400', | ||
'hover:shadow-md' | ||
)} | ||
> | ||
<CardHeader className="flex flex-row items-start gap-2 space-y-0"> | ||
<TaskTextarea | ||
taskId={task.id} | ||
initialTitle={task.title} | ||
onTitleChange={handleTitleChange} | ||
/> | ||
<Button | ||
variant="ghost" | ||
type="button" | ||
asChild | ||
className="hover:text-primary px-2 hover:bg-transparent" | ||
> | ||
<Link to={`/${projectId}/board/${task.id}`} className="p-0"> | ||
<PanelLeftOpen className="h-6 w-6" /> | ||
</Link> | ||
</Button> | ||
</CardHeader> | ||
<CardContent className="flex items-end justify-between"> | ||
<div className="flex flex-wrap gap-1"> | ||
{task.labels.map((label) => ( | ||
<Badge key={label.id} style={{ backgroundColor: label.color }}> | ||
{label.name} | ||
</Badge> | ||
))} | ||
</div> | ||
<AssigneeAvatars assignees={task.assignees} /> | ||
</CardContent> | ||
{task.subtasks.total > 0 && ( | ||
<CardFooter className="flex items-center justify-between space-y-0"> | ||
<SubtaskProgress | ||
total={task.subtasks.total} | ||
completed={task.subtasks.completed} | ||
/> | ||
</CardFooter> | ||
)} | ||
</Card> | ||
</motion.div> | ||
))} | ||
</SectionContent> | ||
<SectionFooter className="w-full"> | ||
<Button | ||
type="button" | ||
variant="ghost" | ||
className="text-blac hover:text-primary w-full border-none px-0 hover:bg-white" | ||
className="w-full border-none px-0 text-black" | ||
onClick={() => handleCreateTask(section.id)} | ||
> | ||
<PlusIcon /> | ||
Add Task | ||
</Button> | ||
</SectionDropdownMenu> | ||
</SectionHeader> | ||
<SectionContent | ||
key={section.id} | ||
className="flex w-full flex-1 flex-col items-center gap-2 overflow-y-auto pt-1" | ||
onDragOver={(e) => handleDragOver(e, section.id)} | ||
onDragLeave={handleDragLeave} | ||
onDrop={(e) => handleDrop(e, section.id)} | ||
onDragEnd={handleDragEnd} | ||
> | ||
{section.tasks.map((task) => ( | ||
<motion.div | ||
key={task.id} | ||
layout | ||
layoutId={task.id.toString()} | ||
draggable | ||
initial={{ opacity: 1, zIndex: 1 }} | ||
animate={{ | ||
zIndex: task.id === belowTaskId ? 50 : 1, | ||
scale: task.id === belowTaskId ? 1.02 : 1, | ||
}} | ||
transition={{ | ||
layout: { duration: 0.3 }, | ||
scale: { duration: 0.2 }, | ||
}} | ||
style={{ position: 'relative' }} | ||
onDragStart={(e) => | ||
handleDragStart(e as unknown as DragEvent<HTMLDivElement>, section.id, task.id) | ||
} | ||
onDrop={(e) => handleDrop(e, section.id)} | ||
onDragOver={(e) => { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
handleDragOver(e, section.id, task.id); | ||
}} | ||
onDragLeave={handleDragLeave} | ||
> | ||
<Card | ||
className={cn( | ||
'w-56 border bg-white transition-all duration-300 md:w-80', | ||
task.id === belowTaskId && 'border-2 border-blue-400', | ||
'hover:shadow-md' | ||
)} | ||
> | ||
<CardHeader className="flex flex-row items-start gap-2 space-y-0"> | ||
<TaskTextarea | ||
taskId={task.id} | ||
initialTitle={task.title} | ||
onTitleChange={handleTitleChange} | ||
/> | ||
<Button | ||
variant="ghost" | ||
type="button" | ||
asChild | ||
className="hover:text-primary px-2 hover:bg-transparent" | ||
> | ||
<Link to={`/${projectId}/board/${task.id}`} className="p-0"> | ||
<PanelLeftOpen className="h-6 w-6" /> | ||
</Link> | ||
</Button> | ||
</CardHeader> | ||
<CardContent className="flex items-end justify-between"> | ||
<div className="flex flex-wrap gap-1"> | ||
{task.labels.map((label) => ( | ||
<Badge key={label.id} style={{ backgroundColor: label.color }}> | ||
{label.name} | ||
</Badge> | ||
))} | ||
</div> | ||
<AssigneeAvatars assignees={task.assignees} /> | ||
</CardContent> | ||
{task.subtasks.total > 0 && ( | ||
<CardFooter className="flex items-center justify-between space-y-0"> | ||
<SubtaskProgress | ||
total={task.subtasks.total} | ||
completed={task.subtasks.completed} | ||
/> | ||
</CardFooter> | ||
)} | ||
</Card> | ||
</motion.div> | ||
))} | ||
</SectionContent> | ||
<SectionFooter className="w-full"> | ||
<Button | ||
variant="ghost" | ||
className="w-full border-none px-0 text-black" | ||
onClick={() => handleCreateTask(section.id)} | ||
> | ||
<PlusIcon /> | ||
Add Task | ||
</Button> | ||
</SectionFooter> | ||
</Section> | ||
))} | ||
</AnimatePresence> | ||
</SectionFooter> | ||
</Section> | ||
))} | ||
</AnimatePresence> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
항상 필요한 로직이라 분리해두었습니다.