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

fix: Adjust merge logic to rely on CRDT timestamps #190

Merged
merged 7 commits into from
Dec 3, 2024
Merged

Conversation

kwaksj329
Copy link
Member

@kwaksj329 kwaksj329 commented Dec 3, 2024

πŸ“‚ μž‘μ—… λ‚΄μš©

closes #188

  • μž‘μ—… λ‚΄μš©

πŸ’‘ μžμ„Έν•œ μ„€λͺ…

1. 동기화 둜직 μˆ˜μ •

  • LWWMap ν΄λž˜μŠ€μ— #sortedStrokes λ°°μ—΄ μΆ”κ°€: μ‹œκ°„μˆœμœΌλ‘œ μ •λ ¬λœ μŠ€νŠΈλ‘œν¬λ“€ 관리
  • findSortedInsertIndex: μ •λ ¬λœ 배열에 μƒˆλ‘œμš΄ 슀트둜크λ₯Ό μ‚½μž…ν•  인덱슀 μ°ΎλŠ” ν•¨μˆ˜
  • insertSortedStroke: μ •λ ¬λœ 배열에 μƒˆλ‘œμš΄ 슀트둜크 μ‚½μž… 및 ν•΄λ‹Ή κ²°κ³Ό λ°˜ν™˜ (middle or end)
  • insertSortedStroke κ°€ λ°˜ν™˜ν•œ 슀트둜크 μ‚½μž… μœ„μΉ˜ middle / end에 따라 λ“œλ‘œμž‰ 둜직 변경됨

2. λ“œλ‘œμž‰ 둜직 μˆ˜μ •

  • 슀트둜크 μ‚½μž… μœ„μΉ˜κ°€ middle인 경우: redraw μˆ˜ν–‰
    • Bκ°€ κ·Έλ¦Ό κ·Έλ¦Ό ➑️ A(λ‚˜)κ°€ 방금 κ·Έλ¦Ό κ·Έλ¦Ό ➑️ B의 슀트둜크 정보 μ†ŒμΌ“μœΌλ‘œ μˆ˜μ‹  λ°›μŒ ➑️
      λ‚΄κ°€ 방금 κ·Έλ¦° 그림보닀 더 λ¨Όμ € 그렀진 κ·Έλ¦Όμ΄λ―€λ‘œ middle μœ„μΉ˜μ— μ‚½μž… λ˜μ–΄μ•Ό ν•˜κ³ , 방금 κ·Έλ¦° 그림보닀 μ•„λž˜μ— 깔렀야함
  • 슀트둜크 μ‚½μž… μœ„μΉ˜κ°€ end인 경우:
    • strokeData.points.lengthκ°€ 2보닀 큰 κ²½μš°λŠ” FILL λͺ¨λ“œμΈ κ²½μš°μž„ ➑️ μ±„μš°κΈ° operation μˆ˜ν–‰
    • strokeData.points.lengthκ°€ 2와 κ°™κ±°λ‚˜ μž‘μ€ κ²½μš°λŠ” PEN λͺ¨λ“œμΈ κ²½μš°μž„ ➑️ 슀트둜크 그리기 operation μˆ˜ν–‰
const renderStroke = useCallback(
    (strokeData: DrawingData, position: 'middle' | 'end') => {
      if (position === 'middle') {
        operation.redrawCanvas();
      } else {
        if (strokeData.points.length > 2) {
          operation.applyFill(strokeData);
        } else {
          operation.drawStroke(strokeData);
        }
      }
    },
    [operation],
  );

3. 보쑰 ν•¨μˆ˜ μΆ”κ°€

  • createDrawingData: style, timestamp 속성 μΆ”κ°€ν•΄μ£ΌλŠ” ν•¨μˆ˜
  • renderStroke: 슀트둜크 λ Œλ”λ§ 둜직 쀑앙화 (redrawCanvas / applyFill / drawStroke)

πŸ“— μ°Έκ³  자료 & κ΅¬ν˜„ κ²°κ³Ό (선택)

timestamp 기반 병합 둜직 반영 μ „

  • μ™Όμͺ½ λΈŒλΌμš°μ € μ°½ + μ•„μ΄νŒ¨λ“œμ—μ„œ λ™μ‹œμ— 같은 μ˜μ—­ FILL 클릭 μ‹œ ➑️ 병합 μ œλŒ€λ‘œ λ˜μ§€ μ•Šμ•„ λ‹€λ₯Έ ν™”λ©΄ λ³΄μž„

2024-12-03.3.00.40.mov

timestamp 기반 병합 둜직 반영 ν›„

  • μ™Όμͺ½ λΈŒλΌμš°μ € μ°½ + μ•„μ΄νŒ¨λ“œμ—μ„œ λ™μ‹œμ— 같은 μ˜μ—­ FILL 클릭 μ‹œ ➑️ λ³‘ν•©λ˜μ–΄ λ™μΌν•œ μΊ”λ²„μŠ€ ν™”λ©΄ λ³΄μž„

2024-12-03.3.19.10.mov

πŸ“’ 리뷰 μš”κ΅¬ 사항 (선택)

🚩 후속 μž‘μ—… (선택)

βœ… μ…€ν”„ 체크리슀트

  • PR 제λͺ©μ„ ν˜•μ‹μ— 맞게 μž‘μ„±ν–ˆλ‚˜μš”?
  • 브랜치 μ „λž΅μ— λ§žλŠ” λΈŒλžœμΉ˜μ— PR을 올리고 μžˆλ‚˜μš”? (main이 μ•„λ‹™λ‹ˆλ‹€.)
  • μ΄μŠˆλŠ” close ν–ˆλ‚˜μš”?
  • Reviewers, Labelsλ₯Ό λ“±λ‘ν–ˆλ‚˜μš”?
  • μž‘μ—… 도쀑 λ¬Έμ„œ μˆ˜μ •μ΄ ν•„μš”ν•œ 경우 잘 μˆ˜μ •ν–ˆλ‚˜μš”?
  • ν…ŒμŠ€νŠΈλŠ” 잘 ν†΅κ³Όν–ˆλ‚˜μš”?
  • λΆˆν•„μš”ν•œ μ½”λ“œλŠ” μ œκ±°ν–ˆλ‚˜μš”?

@kwaksj329 kwaksj329 added 🐞 BugFix Something isn't working πŸ’» FE Frontend Code labels Dec 3, 2024
@kwaksj329 kwaksj329 added this to the Week 6 milestone Dec 3, 2024
@kwaksj329 kwaksj329 self-assigned this Dec 3, 2024
@kwaksj329 kwaksj329 linked an issue Dec 3, 2024 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented Dec 3, 2024

πŸ“š Storybook preview deployed to: Visit Storybook Preview

@kwaksj329 kwaksj329 merged commit 0d40d39 into develop Dec 3, 2024
2 checks passed
Copy link
Contributor

github-actions bot commented Dec 3, 2024

🧹 Storybook preview for PR #190 has been removed.

github-actions bot added a commit that referenced this pull request Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 BugFix Something isn't working πŸ’» FE Frontend Code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CRDT timestamp κΈ°μ€€ merge 둜직 μˆ˜μ •
3 participants