Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Storing hypercubes in localstorage #238

Merged
merged 3 commits into from
Apr 25, 2019
Merged

Storing hypercubes in localstorage #238

merged 3 commits into from
Apr 25, 2019

Conversation

hrigner
Copy link

@hrigner hrigner commented Apr 17, 2019

Fixes #237

@hrigner hrigner requested a review from peol April 17, 2019 14:17
@netlify
Copy link

netlify bot commented Apr 17, 2019

Deploy preview for catwalk-qlikcore ready!

Built with commit 64b7b0c

https://deploy-preview-238--catwalk-qlikcore.netlify.com

@hrigner hrigner changed the title Saving hypercubes to localstorage Storing hypercubes in localstorage Apr 17, 2019
@@ -28,6 +32,41 @@ const Cube = forwardRef(({ app, tableData: { initialColumns }, closeOnClickOutsi
let model = null;
let hypercubeProps = null;

const modifyLocalStorage = (action) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps use something like https://github.com/rehooks/local-storage ?

Copy link
Author

Choose a reason for hiding this comment

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

I don't want to constantly read/write to localstorage (to keep sync with some kind of state). Otherwise it's just replacing one line with another line and also adding a new dependency.

@@ -42,6 +48,22 @@ export function Cubes({ app, closeOnClickOutside }) {
forceUpdate();
}

useEffect(() => {
// Check if cubes are stored in localstorage.
let storedCubes = localStorage.getItem(app.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this can throw an error if local storage is disabled, we probably need to gracefully disable this feature if we cannot use LS.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. I added a check if localstorage is disabled.

@hrigner hrigner requested a review from gabbaxx April 24, 2019 06:05
Copy link
Contributor

@gabbaxx gabbaxx left a comment

Choose a reason for hiding this comment

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

LGTM!

@hrigner hrigner merged commit d803355 into master Apr 25, 2019
@hrigner hrigner deleted the save-hypercubes branch April 25, 2019 12:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store the hypercubes
3 participants