chinchang / web-maker

A blazing fast & offline frontend playground
https://webmaker.app
MIT License
2.58k stars 317 forks source link

Cannot save changes to imported creations #574

Open nhogle opened 1 week ago

nhogle commented 1 week ago

Meta info

While I am logged out, if I import a creation that I had previously exported while logged in, then I cannot save changes to that creation (Save button is not visible).

Use case: I wanted to keep working and save changes to creations while logged out (e.g. I want to work offline because my Internet connection is spotty). So I exported my creations to JSON, then logged out. Now I can work offline and save creations to local storage instead of the cloud. The problem is, if I want to work on my previously-exported creation, then I can import that creation, but I cannot save changes to it. This is due to the isNotMine boolean which is declared here.

It seems the purpose of the isNotMine flag is to prevent users from trying to save or share other users' public creations? I can think of a couple ways to fix this issue:

  1. Reassign (if logged in) the item's createdBy property when importing it, (or delete the property if not logged in?)
  2. Re-think the isNotMine and public sharing logic. If you open a public creation from a URL, shouldn't you be able to fork that creation and work on it within your own workspace? Actually now that I'm looking at this deeper, it appears the app completely breaks when opening a publicly-shared creation (e.g. in a different browser, or in incognito mode). Perhaps I should file that as a separate issue?
chinchang commented 1 week ago

@nhogle Will have a look at this. Though one question - The web app currently has a bug (#563) where it doesn't work in offline state. How are you able to use the web app without Internet? Also, assuming the web app was working in offline state, you don't need to export and logout to be able to work offline. Even in logged in state you can simply work on your creations, without Internet. Your changes sync to the database next time when you come online.

nhogle commented 1 week ago

@chinchang : You're right, I just went back to check, and it looks like I can't run the creations while offline. I was, however, able to import my previously-exported creations (while logged out), and make changes to the code. That was when I discovered that I couldn't save changes. My internet later came back online, so I was able to run the creation again (but still unable to save) so I didn't realize that the offline state was preventing running the creation.

As for saving while offline (and logged in): I see that this works if you do the following:

  1. Open a creation while online and logged in.
  2. Go offline (disconnect wifi)
  3. Make some changes
  4. Click the "Save" button (I have my auto-save set to "off"). Save button is now disabled with a spinner.
  5. Go back online
  6. The save button is re-enanabled and the spinner goes away. (And presumably the creation is saved).

However, if you make multiple sets of changes while offline, and you try saving between those changes, then we run into problems:

  1. Open a creation while online and logged in.
  2. Go offline (disconnect wifi)
  3. Make some changes
  4. Click the "Save" button. Save button is now disabled with a spinner.
  5. Make some more changes
  6. Try clicking the "Save" button again - you cannot.
  7. Go back online
  8. The save button is re-enanabled and the spinner goes away. But! if you switch to another creation, and back to the first creation, then only the first set of changes was persisted.

I didn't test this while logged out. Does this help?

nhogle commented 1 week ago

Update: I created issue #575 to document the crash issue that I'm noticing when I tried loading the publicly-shared creation in a fresh browser.

chinchang commented 1 week ago

Open a creation while online and logged in. Go offline (disconnect wifi) Make some changes Click the "Save" button (I have my auto-save set to "off"). Save button is now disabled with a spinner. Go back online The save button is re-enanabled and the spinner goes away. (And presumably the creation is saved).

These steps you are noticing on your end seem different from the expected behaviour. In offline state, if you press save button, the creation should still save with a message - "Item saved locally. Will save to account when you are online".

CleanShot 2024-11-09 at 15 54 56@2x

Don't you see this message on saving in offline state?