-
Notifications
You must be signed in to change notification settings - Fork 14
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
Added commitWith() method to specify message/timestamp and exposing changes via changeByHash() #129
Added commitWith() method to specify message/timestamp and exposing changes via changeByHash() #129
Conversation
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.
Conceptually, looks good to me, but I'd like @alexjg to chime in on the Rust code and any implications for exposing the Change contents that I might be missing.
Was a little surprised you replicated/shadowed Change into Automerge-swift rather than using extensions to add pieces to the underlying one, but no qualms with how you did it - it's explicit and clear on what's happening there.
For the optional metadata save component of this, I would like to make either, or other, of those parameters actually optional and handle the missing pieces inside that method appopriately. Ideally, there'd be tests illustrating and working passing in an optional message, an optional timestamp, or both (which seems pathologically silly - but possible) - and what that means (for example - does calling this method with a nil date mean "please save the current timestamp", or is it functionally the same as calling the non-optional-enabled save()
method?)
I added some suggested updates to documentation changes on the save method - there's changes that'll be needed in overall curation and other documentation locations, but I can handle integrating those post-merge without issue.
Thanks for the feedback @heckj @alexjg. I separated out |
Re. the |
We currently (with the older version of the swift bindings) use the
timestamp
field of the changes in order to determine when a document was last modified for display to the user in our application. I was directed to #104 where this feature has also been discussed. While changes to the underlyingAutoCommit
type in the core automerge library would likely be better long-term, this PR aims to provide a more targeted solution for this swift library. In the normal usage of this library with anAutomergeEncoder
, the underlying transaction is made at the point that save() is called. Therefore, we can make this transaction more explicit and pass through commit options (message
/timestamp
).I also needed a way to retrieve these commit options later, so added a new
changeByHash(hash:)
method which grabs a fullChange
object from the underlying automerge document for a given hash. This way, we can easily get the timestamp for the latest changes by calling this method on eachhead
of the document.I added a new test which showcases both of these new APIs.
As an aside, when I ran the
build-xcframework.sh
script locally, I ended up with a ton of other local changes to the generated code (mostly style changes). I removed those from the PR but would be great to know if there's a way to make this less noisy moving forwards.