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

Refactor LocalStorage and associated hooks #11625

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from

Conversation

somebody1234
Copy link
Contributor

@somebody1234 somebody1234 commented Nov 22, 2024

Pull Request Description

  • Close https://github.com/enso-org/cloud-v2/issues/1586
    • Refactor localStorage to use functionality returned by a single function, rather than registering keys plugin-style when modules are loaded.
      • This avoids errors when a module tries to read a key when the module defining the key has not yet been imported.

Important Notes

None

Testing Instructions

  • Make sure local storage keys are loaded and saved as appropriate:
    • ToS and Privacy Policy modal should not reappear on reload
    • Displayed columns
    • Sidebar open state
    • Local root directory (accessible from gear icon beside "Local" category)
    • Extra local root directories (below the "Local" category in the sidebar - added by "add folder")

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@somebody1234 somebody1234 added CI: No changelog needed Do not require a changelog entry for this PR. g-dashboard x-refactor Changes that should not be visible to the end-user labels Nov 22, 2024
@somebody1234
Copy link
Contributor Author

@MrFlashAccount for CR

} = defineLocalStorageKey('localRootDirectories', {
schema: (z) => z.string().array().readonly(),
})
export const { use: useLocalRootDirectories, useState: useLocalRootDirectoriesState } =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it still use? Is it a hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. it uses localStorage from the context, not sure if it's necessary tbh but i think removing the LocalStorageProvider is out of scope for this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowadays LocalStorage is a Singleton class, we can avoid using it from the context to make it possible to manipulate the storage state outside of the components, I think

@somebody1234 somebody1234 force-pushed the wip/sb/refactor-localstorage branch from 7cce37e to 82e79fe Compare December 11, 2024 13:08
@somebody1234
Copy link
Contributor Author

@MrFlashAccount might you have time to review this one soonish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. g-dashboard x-refactor Changes that should not be visible to the end-user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants