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

PKG -- [fcl] Default to localStorage #2001

Merged
merged 10 commits into from
Nov 13, 2024
Merged

PKG -- [fcl] Default to localStorage #2001

merged 10 commits into from
Nov 13, 2024

Conversation

jribbink
Copy link
Contributor

@jribbink jribbink commented Nov 13, 2024

Closes #2002

This PR includes the following:

  • Switch default storage to localStorage
  • Export LOCAL_STORAGE and SESSION_STORAGE utilities
  • Gets rid of the fcl.storage.default key and passes this as an initialization parameter instead (I feel that the former is an anti-pattern)

FCL's actor model creates global singletons in the window.FCL_REGISTRY object. As config is an actor, this means that fcl.storage.default is globally shared in the DOM. Because extension wallets (e.g. Flow Wallet) load FCL within a content script, it means that the default storage is overwritten (regresses to sessionStorage, in spite of changing default in FCL).

In an ideal world, FCL would not have such side effects. This is the motivation for moving the storage to an initialization parameter instead. It helps bring things one step closer to eliminating some of this global state in FCL.

Copy link

changeset-bot bot commented Nov 13, 2024

🦋 Changeset detected

Latest commit: 427fb46

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

This PR includes changesets to release 4 packages
Name Type
@onflow/fcl-core Minor
@onflow/fcl Minor
@onflow/fcl-react-native Patch
@onflow/fcl-wc 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

@jribbink jribbink changed the title Jribbink/localstorage Default to localStorage Nov 13, 2024
@jribbink jribbink changed the title Default to localStorage PKG -- [fcl] Default to localStorage Nov 13, 2024
@jribbink jribbink marked this pull request as ready for review November 13, 2024 19:47
@jribbink jribbink requested a review from a team as a code owner November 13, 2024 19:47
@jribbink jribbink merged commit bac8c54 into master Nov 13, 2024
1 check passed
@jribbink jribbink deleted the jribbink/localstorage branch November 13, 2024 23:49
@github-actions github-actions bot mentioned this pull request Nov 27, 2024
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.

Default to Local Storage
3 participants