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: Update undo/redo logic to align with CRDT changes #193

Merged
merged 6 commits into from
Dec 4, 2024

Conversation

kwaksj329
Copy link
Member

@kwaksj329 kwaksj329 commented Dec 3, 2024

๐Ÿ“‚ ์ž‘์—… ๋‚ด์šฉ

closes #192

  • CRDT ๋กœ์ง ๋ณ€๊ฒฝ์— ๋”ฐ๋ผ undo/redo ๋กœ์ง ์ˆ˜์ •

๐Ÿ’ก ์ž์„ธํ•œ ์„ค๋ช…

1. RegisterState ๊ตฌ์กฐ ๋ณ€๊ฒฝ

  • ๊ธฐ์กด์—๋Š” RegisterState๊ฐ€ ๋ฐฐ์—ด ํ˜•ํƒœ([peerId, timestamp, value])๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
  • undo/redo ์‹œ ์ŠคํŠธ๋กœํฌ์˜ ํ™œ์„ฑ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ๋ณ„๋„์˜ isDeactivated ํ”Œ๋ž˜๊ทธ๋ฅผ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.
export type RegisterState<T> = {
  peerId: string;
  timestamp: number;
  value: T;
  isDeactivated?: boolean;
};

2. LWWMap์˜ ์ƒํƒœ ๊ด€๋ฆฌ ๋ณ€๊ฒฝ

  • ๊ธฐ์กด์—๋Š” ์ŠคํŠธ๋กœํฌ๋ฅผ undoํ•  ๋•Œ value๋ฅผ null๋กœ ์„ค์ •ํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ–ˆ์œผ๋‚˜, ์ด์ œ๋Š” isDeactivated ํ”Œ๋ž˜๊ทธ๋ฅผ ํ†ตํ•ด ์ŠคํŠธ๋กœํฌ์˜ ํ™œ์„ฑ ์ƒํƒœ๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
  • ์ŠคํŠธ๋กœํฌ์˜ value๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•˜๋ฉด์„œ isDeactivated ์ƒํƒœ๋งŒ ํ† ๊ธ€ํ•˜์—ฌ undo/redo๋ฅผ ์ฒ˜๋ฆฌํ•˜๋„๋ก ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.

3. ์บ”๋ฒ„์Šค Redraw ๋ณ€๊ฒฝ

  • getActiveStrokes ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ํ™œ์„ฑํ™”๋œ ์ŠคํŠธ๋กœํฌ๋งŒ ํ•„ํ„ฐ๋งํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ์บ”๋ฒ„์Šค redraw ์‹œ ๋น„ํ™œ์„ฑํ™”๋œ ์ŠคํŠธ๋กœํฌ๋Š” ์ž๋™์œผ๋กœ ์ œ์™ธ๋ฉ๋‹ˆ๋‹ค.
  • mergeRegister์—์„œ ์ŠคํŠธ๋กœํฌ์˜ ํ™œ์„ฑ ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งŒ sortedStrokes ๋ฐฐ์—ด์„ ์—…๋ฐ์ดํŠธํ•˜๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“— ์ฐธ๊ณ  ์ž๋ฃŒ & ๊ตฌํ˜„ ๊ฒฐ๊ณผ (์„ ํƒ)

2024-12-04.1.53.28.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
Copy link
Contributor

github-actions bot commented Dec 3, 2024

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

Copy link
Contributor

github-actions bot commented Dec 4, 2024

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

@kwaksj329 kwaksj329 merged commit d7fdea8 into develop Dec 4, 2024
2 checks passed
Copy link
Contributor

github-actions bot commented Dec 4, 2024

๐Ÿงน Storybook preview for PR #193 has been removed.

github-actions bot added a commit that referenced this pull request Dec 4, 2024
@kwaksj329 kwaksj329 deleted the feature/#192 branch December 4, 2024 08:50
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 ๋กœ์ง ๋ณ€๊ฒฝ์— ๋”ฐ๋ฅธ undo/redo ๋กœ์ง ์ˆ˜์ •
3 participants