Skip to content

Add LoroMovableList.isAttached() #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

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Sources/Loro/LoroFFI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2685,6 +2685,14 @@ public protocol LoroMovableListProtocol : AnyObject {

func insertTreeContainer(pos: UInt32, child: LoroTree) throws -> LoroTree

/**
* Whether the container is attached to a document
*
* The edits on a detached container will not be persisted.
* To attach the container to the document, please insert it into an attached container.
*/
func isAttached() -> Bool

func isEmpty() -> Bool

func len() -> UInt32
Expand Down Expand Up @@ -2915,6 +2923,19 @@ open func insertTreeContainer(pos: UInt32, child: LoroTree)throws -> LoroTree {
FfiConverterTypeLoroTree.lower(child),$0
)
})
}

/**
* Whether the container is attached to a document
*
* The edits on a detached container will not be persisted.
* To attach the container to the document, please insert it into an attached container.
*/
open func isAttached() -> Bool {
return try! FfiConverterBool.lift(try! rustCall() {
uniffi_loro_fn_method_loromovablelist_is_attached(self.uniffiClonePointer(),$0
)
})
}

open func isEmpty() -> Bool {
Expand Down Expand Up @@ -8125,6 +8146,9 @@ private var initializationResult: InitializationResult = {
if (uniffi_loro_checksum_method_loromovablelist_insert_tree_container() != 33670) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_loro_checksum_method_loromovablelist_is_attached() != 50724) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_loro_checksum_method_loromovablelist_is_empty() != 44651) {
return InitializationResult.apiChecksumMismatch
}
Expand Down
9 changes: 8 additions & 1 deletion Tests/LoroTests/LoroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ final class LoroTests: XCTestCase {
let s = text.toString()
XCTAssertEqual(s, "bc")
}


func testMovableList(){
let doc = LoroDoc()
let movableList = doc.getMovableList(id: "movableList")
XCTAssertTrue(movableList.isAttached())
XCTAssertFalse(LoroMovableList().isAttached())
}

func testSync(){
let doc = LoroDoc()
try! doc.setPeerId(peer: 0)
Expand Down
14 changes: 7 additions & 7 deletions loro-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion loro-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ path = "src/uniffi-bindgen.rs"

[dependencies]
# loro-ffi = { path = "../../loro/crates/loro-ffi" }
loro-ffi = { git = "https://github.com/loro-dev/loro.git", rev = "a9f669d173807b80dde7ffef7f467c8a57fc5b1f" }
loro-ffi = { git = "https://github.com/loro-dev/loro.git", rev = "d1611d6f83d79152ff1f912b7f31b39875b16015" }
uniffi = { version = "0.28" }

[build-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions loro-rs/src/loro.udl
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ interface LoroMovableList{
/// To attach the container to the document, please insert it into an attached container.
constructor();

/// Whether the container is attached to a document
///
/// The edits on a detached container will not be persisted.
/// To attach the container to the document, please insert it into an attached container.
boolean is_attached();

/// Get the container id.
ContainerID id();

Expand Down
Loading