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

Cannot save changes to imported creations #574

Open
nhogle opened this issue Nov 7, 2024 · 6 comments
Open

Cannot save changes to imported creations #574

nhogle opened this issue Nov 7, 2024 · 6 comments
Labels

Comments

@nhogle
Copy link
Contributor

nhogle commented Nov 7, 2024

Meta info

  • Is this a bug or suggestion?: bug
  • Version (click on help icon in footer): 6.4.0
  • Context - Web app, Chrome extension or both?: Web app

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
Copy link
Owner

@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.

@chinchang chinchang added the bug label Nov 7, 2024
@nhogle
Copy link
Contributor Author

nhogle commented Nov 8, 2024

@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
Copy link
Contributor Author

nhogle commented Nov 8, 2024

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
Copy link
Owner

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?

@nhogle
Copy link
Contributor Author

nhogle commented Nov 18, 2024

@chinchang : I finally have had a chance to dig into this further, and I see how the app is supposed to show the "saved locally" message if the browser is offline. In my case, the browser's navigator.onLine property is returning true, even though my Wi-Fi connection is disconnected. I believe this is actually pretty common, since many people have virtual network adaptors due to VPN or other virtualized networking that they may have set up on their machines.

From the MDN docs:

Browsers implement this property differently.
In Chrome and Safari, if the browser is not able to connect to a local area network (LAN) or a router, it is offline; all other conditions return true. So while you can assume that the browser is offline when it returns a false value, you cannot assume that a true value necessarily means that the browser can access the internet. You could be getting false positives, such as in cases where the computer is running a virtualization software that has virtual ethernet adapters that are always "connected." Therefore, if you really want to determine the online status of the browser, you should develop additional means for checking

So in this case, in ItemService#setItem(), the Firestore's setDoc's promise never resolves, and also navigator.onLine check fails to return a short-circuit promise here. This meansitemService.setItem()'s promise never resolves, which means the onSaveComplete() function doesn't get called and the UI remains in the "saving" state, i.e. the Save button remains disabled and we don't see any message about the item being saved locally or non-locally.

So if navigator.onLine isn't reliable, then it looks like we would need an entirely different approach to saving while offline... Here is a StackOverflow issue with someone else complaining about this very issue with Firestore.

@chinchang
Copy link
Owner

Had been quite occupied since last few days. Will take a look at this again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants