-
Notifications
You must be signed in to change notification settings - Fork 1
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
Usage documentation #6
Comments
Yep, sorry. There is also no online docs right now. I ran out of time with this one, but you should find some infos at #1. |
Quick notes: import { getBuilder } from '@nextcloud/browser-storage'
// browser storage, clears after the browser is closed (uses sessionStorage internally)
browserStorage = getBuilder('appname').build()
// survives page changes and stays after log out (uses localStorage internally)
persistentStorage = getBuilder('appname').persist().build()
// survives page changes but clears after logging out (uses localStorage internally)
userSessionStorage = getBuilder('appname').clearOnLogout().build()
// same as `clearOnLogout()` alone ??
userSessionStorage2 = getBuilder('appname').persist().clearOnLogout().build() @ChristophWurst can you clarify if I got it right ? we could also use the proposed naming in the code |
|
The original idea was to include this package in the server and call the clear there as one central code to do this. It's not intended for the app to deal with this. |
|
ah yes, it's only if you change the URL. |
adjusted to "// browser storage, clears after the browser is closed (uses sessionStorage internally)" |
I just discovered that all of localStorage gets cleared on logout (given that "clear=1" is passed and it is when using the top right menu): https://github.com/nextcloud/server/blob/master/core/src/login.js#L34 so even when using "persist()" |
Was on purpose, because CardDav/Caldav stuff was cached in there and thus needs to be cleaned as it would otherwise leak personal data. At least that is what I remember ... Was done by @georgehrke |
So let's switch that to session storage if the data should not survive?! |
|
Well sure, but at least browser storage is even more wrong for sensitive data |
Of course |
I tried to infer usage from the source code but it isn't as straightforward.
Would be good to add some usage examples in the README for volatile and persistent, and maybe best practices.
The text was updated successfully, but these errors were encountered: