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

Autosaving & autoloading #2

Merged
merged 5 commits into from Jun 18, 2021
Merged

Autosaving & autoloading #2

merged 5 commits into from Jun 18, 2021

Conversation

alexlitty
Copy link
Collaborator

@alexlitty alexlitty commented Jun 17, 2021

This looks like a good prerequisite for importing and exporting to disk.

Includes some new utilities (isString, isObject). Tried to match the existing coding style, do let me know if I missed anything.

@alexlitty alexlitty requested a review from maximecb June 17, 2021 06:54
public/main.js Outdated Show resolved Hide resolved
public/main.js Outdated
}
}

window.onunload = function ()
{
// Save the graph when unloading the page
localStorage.setItem('graph', exportData());
localStorage.setItem('model', model.serialize());
Copy link
Owner

Choose a reason for hiding this comment

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

We should probably call the value in the local storage 'project' or 'state', seems more descriptive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps latestModelState, just in case other aspects of the project require state later on (UI configurations, maybe)?

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Having latestModelState = {state: ...} felt redundant, I went with latestModelData instead. Still cool with you?

Copy link
Owner

Choose a reason for hiding this comment

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

Sure

public/main.js Outdated Show resolved Hide resolved
public/main.js Outdated Show resolved Hide resolved
Copy link
Owner

@maximecb maximecb left a comment

Choose a reason for hiding this comment

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

I can tell that you are an experienced programmer by how quickly you are able to jump in.

I added a few comments, I hope you can forgive my nitpicking. You did a good job.

For the next step, I would like to add "Open" and "Save" links in the top bar to the right of "New" and connect those with file pickers. I would prefer we put the code that deals with the buttons and file picking in main.js since it's more to do with UI than the mechanics of the model.

@alexlitty
Copy link
Collaborator Author

Thank you. You made a great foundation to navigate through -- Thanks for that too!

Nitpick as critically as you'd like, nothing personal at all. I'll adapt to your preferences and wants for the project.

I'll update this PR with requested changes and start a new PR for the Open/Save portion.

@alexlitty alexlitty requested a review from maximecb June 18, 2021 01:35
@maximecb maximecb merged commit 16d82d6 into main Jun 18, 2021
@maximecb maximecb deleted the litty/autosaving branch June 18, 2021 04:09
@maximecb
Copy link
Owner

Persistence works well on my end, and the "New" button works too. Good job 👍

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.

None yet

2 participants