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

project save/load to browser #158

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

project save/load to browser #158

wants to merge 12 commits into from

Conversation

magland
Copy link
Collaborator

@magland magland commented Jul 26, 2024

Save projects to browser (uses IndexedDB)

Click "Save Project" button, then "Save to Browser"

It will be saved by the title of the project. If there already exists such a project, user will be prompted to replace.

Click "Load Project" button. Below the upload box the browser projects are listed. You can also click the delete icon to delete browser projects.

Copy link
Collaborator

@jsoules jsoules left a comment

Choose a reason for hiding this comment

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

A couple minor tweaks and questions.

I agree that we should give some warning that this mode of saving should be considered potentially volatile, since a cleared cache etc. would remove it.

gui/src/app/pages/HomePage/BrowserProjectsInterface.ts Outdated Show resolved Hide resolved
gui/src/app/pages/HomePage/LoadProjectWindow.tsx Outdated Show resolved Hide resolved
type SaveToBrowserViewProps = {
fileManifest: Partial<FileRegistry>;
title: string;
onClose: () => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know we have this elsewhere in this file too--what's the intended use case? As far as I can see, it's just hard-coded to a no-op?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed the name to onCancel which should be clearer. This is called if user clicks the CANCEL button.

Comment on lines 112 to 117
useEffect(() => {
const bpi = new BrowserProjectsInterface();
bpi.listProjects().then((titles) => {
setBrowserProjectTitles(titles);
});
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that there is a race condition here if you have two tabs open: saving (or deleting) a project in one will not update the other.

I think this is probably okay, it's not really an intended operational mode or likely to come up, but I wanted to point it out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see what you mean, but this is not going to be a problem since retrieving from browser storage is fast enough.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's a matter of save/retrieve speed--it's if you have the window open already, there isn't anything triggering an update. (At least that's how it looked when I was playing around with it.)

Again, I think the steps to trigger are kind of far-fetched, so I'm not worried, but just want to note everything I see.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I see! Didn't read carefully enough :)

@magland
Copy link
Collaborator Author

magland commented Jul 29, 2024

Is this okay to merge @WardBrian @jsoules ?

Copy link
Collaborator

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

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

Two things that stood out to me when trying it just now

gui/src/app/pages/HomePage/LoadProjectWindow.tsx Outdated Show resolved Hide resolved
component="button"
underline="none"
>
{title}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to me like it would also be incredibly helpful to store a timestamp (we could put this in meta.json in general). That way we could display it here if we supported multiple local saves by the same name, or display it in the "are you sure you want to overwrite" dialog so people know when the to-be-overwritten project comes from

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree it would be helpful. But I'm wary about including it in meta.json as there's nothing that is enforcing the accuracy of that information if someone edits the project outside of SP. And for Gists, this information would be available independent of the content of meta.json.

Let me put the timestamp in the browser storage record and we'll see how that looks.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a good idea (modulo all the usual complications about timestamps/time zones) but might be for a different PR? I'd want to see the other forms of persistence be aware of it also.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(Didn't see your message Jeff until just now.)

I added timestamps for the saved browser projects, but it's not in meta.json.

The timestamps are now shown (in the form of "time-ago-strings", like "3 min ago").

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

@magland
Copy link
Collaborator Author

magland commented Jul 31, 2024

This one is on hold for now because there are some questions about whether we want to have this functionality. Will revisit later.

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.

3 participants