youperiod.app icon indicating copy to clipboard operation
youperiod.app copied to clipboard

Need to implement "persistent storage" capability

Open getify opened this issue 2 years ago • 2 comments

Need to implement JS functionality (and some UI and carefully considered wording to the user) around opting the storage of this app (indexDB) into "persistent storage" mode.

More info here: https://web.dev/persistent-storage/

This is a tricky piece of functionality, because how it works and how it appears to users varies cross browser, and it can also sound a little "scary" to users -- like in violation of the core principles of this project -- if messaged poorly.

In detail...

  1. We need to check if the user's device supports "persistent storage" (a web platform feature). If not, we need to explain to the user the implications of not having their data stored in such a protected/resilient state, and the risks of them continuing to save their information on that device and in this app.

  2. But if the device supports this feature, need to have a message that comes up, sometime after the user has registered and logged in the first time, but not right away. Probably when they go to enter their first piece of "real" data (not just account info or settings).

  3. The messaging needs to be something along the lines of (but not this exact wording, because I'm not a skilled copy writer):

    Since the data you enter in this app only ever resides on this device, and we assume you want to keep your data as safe as possible, we'd like to request the device to elevate its protection of your data in this app -- what is referred to as "persistent storage" (again, on this device only). This protection will help prevent your important information from accidentally being discarded by the browser or device, as happens on occasion with typical web data. If you agree, once you click this button, your device may offer you an additional confirmation prompt, or it may simply grant the permission, depending on your device type and settings.

    Like I said, that's wordy and needs a lot of cleanup. But it's a tricky and delicate thing to explain to the user why we need to ask this, and also to help them understand what the device prompt is about (in cases where the device pops it up) so they're not surprised by it and deny the permission.

    We also need to carefully but firmly explain that if they do NOT agree to this, their data is less safe and subject to potential loss at some point that's not much in our (or their!) control.

  4. Once we have properly and successfully received the user's permission to do this, we call an API to try to get the persistent storage mode activated. A promise will resolve letting us know if that was successful. If so, great. If not, we need to message the user similarly to if the device didn't support such storage, explaining the risks of continuing use without that protection in place.

  5. Moreover, there's another API we need to call from time to time, perhaps once per session, but not all the time, which essentially re-checks to see if the storage is persistent. Once granted, it should stay granted forever, but it's possible some devices/settings might someday revoke it. If it has been revoked, we might end up then needing to re-prompt the user for continued persistent storage permission, so again need careful messaging like the above to warn them about what's happening.

getify avatar Jul 06 '22 13:07 getify

Can I work on this feature?

detronetdip avatar Jul 09 '22 06:07 detronetdip

Yes, if you'd like to add it to the existing client code, that might be useful effort/exploration.

getify avatar Jul 09 '22 12:07 getify