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

feat: Add isDeleted() method to containers #555

Merged
merged 2 commits into from
Nov 12, 2024
Merged

feat: Add isDeleted() method to containers #555

merged 2 commits into from
Nov 12, 2024

Conversation

zxch3n
Copy link
Member

@zxch3n zxch3n commented Nov 12, 2024

Add Container Deletion Status Check

This PR adds the ability to check if a container has been deleted through the new isDeleted() method available on all container types.

Changes

  • Added isDeleted() method to the ContainerTrait trait
  • Implemented isDeleted() for all container types:
    • LoroText
    • LoroMap
    • LoroList
    • LoroTree
    • LoroMovableList
    • LoroCounter
    • LoroUnknown
  • Fixed tracking of deleted containers in tree operations
  • Added comprehensive tests covering various deletion scenarios:
    • Tree node deletion
    • Movable list container replacement
    • Map value overwrite
    • Remote deletion sync

Testing

Added test cases to verify deletion status:

  • Basic container deletion through tree operations
  • Container replacement in movable lists
  • Map value overwriting
  • Cross-document deletion sync

Usage Example

const doc = new LoroDoc();
const map = doc.getMap("map");
const sub = map.setContainer("sub", new LoroMap());
expect(sub.isDeleted()).toBe(false);

map.set("sub", "value"); // Replace container with primitive
expect(sub.isDeleted()).toBe(true);

- Add isDeleted() method to all container types (Text, Map, List, Tree, etc.)
- Fix deletion tracking for containers in tree operations
- Add tests to verify deletion state across different scenarios
@zxch3n zxch3n merged commit ee26952 into main Nov 12, 2024
1 check passed
@zxch3n zxch3n deleted the feat-is-deleted branch November 12, 2024 13:15
rteqs pushed a commit to rteqs/loro that referenced this pull request Nov 13, 2024
* feat: Add isDeleted() method to containers

- Add isDeleted() method to all container types (Text, Map, List, Tree, etc.)
- Fix deletion tracking for containers in tree operations
- Add tests to verify deletion state across different scenarios

* chore: fix redundant field names

---------

Co-authored-by: Leon Zhao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants