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

Persist private preferences to keystore #657

Merged
merged 13 commits into from
Sep 6, 2024
Merged

Conversation

rygine
Copy link
Collaborator

@rygine rygine commented Sep 5, 2024

Summary

This PR adds caching of private preferences to the JS SDK.

  • Upgraded @xmtp/proto for encoding of a private preferences action map
  • Added a private preferences store to manage persisting of actions
  • Added new methods to InMemoryKeystore to interact with the private preferences store
  • Refactored Contacts class to use the private preferences store
  • Removed deprecated/unused lastConsentListEntryTimestamp method from Contacts class

Notes

  • The use of for loops rather than for..of is intentional as it's more performant with a large number of iterations.
  • The persistence of private preferences relies on the existing persistConversations option. I think they should be tied together and having a separate option would create unnecessary complexity.
  • The actions are key'd by their timestamp, which should be unique. The use of their timestamp is necessary in order to process them in the proper order. While it's technically possible to have 2 separate actions published with the same timestamp, it's not something we should worry about under normal circumstances. In the case that there are 2 actions with the same timestamp, the first one returned by the network will be the one used. Any subsequent actions with a duplicate timestamp will be ignored.

@rygine rygine requested a review from a team September 5, 2024 18:46
Copy link

changeset-bot bot commented Sep 5, 2024

🦋 Changeset detected

Latest commit: dafd1e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@xmtp/xmtp-js Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rygine rygine force-pushed the rygine/persist-consent branch from 7f6a0b0 to cc5be9b Compare September 5, 2024 21:37
Copy link

cloudflare-workers-and-pages bot commented Sep 5, 2024

Deploying xmtp-js-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: dafd1e5
Status: ✅  Deploy successful!
Preview URL: https://3b5f3a9d.xmtp-js.pages.dev
Branch Preview URL: https://rygine-persist-consent.xmtp-js.pages.dev

View logs

@rygine rygine requested review from a team as code owners September 6, 2024 15:50
@rygine rygine force-pushed the rygine/persist-consent branch from 859b37e to d3b13b7 Compare September 6, 2024 15:50
@rygine rygine force-pushed the rygine/persist-consent branch from 4343708 to 8b74f03 Compare September 6, 2024 20:02
@rygine rygine merged commit 3dda475 into main Sep 6, 2024
13 checks passed
@rygine rygine deleted the rygine/persist-consent branch September 6, 2024 20:08
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