Comments (16)
We need nearly the complete storage interface except for the storage . key ( n )
method and the length property.
from nextcloud-browser-storage.
So lets do this as a V1 and then continue from there?
from nextcloud-browser-storage.
We should have a common/protected namespace for a guest username, so talk, deck, text,... Can all use the same guest name
👍 for scoped/namespaced storage per app.
What about clearing data? Anything sensitive should be wiped on logout. But apparently jsxc has data that should persist. Do we need two types of storage/values?
from nextcloud-browser-storage.
For Talk we would mostlikely only add stuff that would be okay to persist like:
Guest name
Sidebar opened/closed
Microphone/Camera on/off (and in the future selection in case you have multiple)
from nextcloud-browser-storage.
For calendar it would be nice to keep a list of calendars. So something we definitely have to wipe on logout.
from nextcloud-browser-storage.
also cc @georgehrke @juliushaertl @skjnldsv :)
from nextcloud-browser-storage.
We should have a common/protected namespace for a guest username, so talk, deck, text,... Can all use the same guest name
from nextcloud-browser-storage.
what are the basic operation you need for jsxc?
I need a way to store some data in a way that it's not deleted after logout, but I think in general Nextcloud should only delete data which was stored by an Nextcloud App (using this new api for example). Otherwise Nextcloud potentially messes with other applications running under the same domain, due to the fact that NC supports installation in a subdirectory.
from nextcloud-browser-storage.
Sure. As soon as we have our own abstraction that can scope the storage, it should be also trivial to scope that.
from nextcloud-browser-storage.
Something like the following should do the trick:
class Storage {
private prefix = 'NC/';
constructor(prefix, private backend = localStorage) {
this.prefix += prefix + '/';
}
public setItem() {
let args = [...arguments];
// there is probably a smarter solution
args[0] = this.prefix + args[0];
this.backend.apply(this.backend, args);
}
// wrap all other methods
public clear() {
let prefixRegex = new RegExp('^' + this.prefix);
let keys = Object.keys(this.backend);
// we could also filter the array
for (let key of keys) {
if (prefixRegex.test(key)) {
this.backend.removeItem(key);
}
}
}
}
from nextcloud-browser-storage.
Let's leave implementation aside.
setItem
and clear
are the only operations you need? What about retrieving an element?
from nextcloud-browser-storage.
How do we want to handle the requirement app A wants data cleared on logout, app B doesn't? I started the implementation at #2. I used a similar API as we have for https://nextcloud.github.io/nextcloud-logger/. The builder already has an option for persist, but right now that just determines if you'll get session storage or local storage. There could be something similar that says I want persistend storage that survives logouts. It's just a matter of storing this flag internally and checking on clear
.
from nextcloud-browser-storage.
Please see #2 :)
from nextcloud-browser-storage.
I was thinking a lot about this in the last few days and I think the whole idea to implement a session store on top of a persistent storage is crazy. If an app wants to store some information only for the current session, it should use the session storage (this could also be cleared on logout) and if an app wants to store information persistent it should use the local storage. This was probably the intention when those interfaces were specified.
In the case that NC really wants to clear the persistent storage, there should be a possibility for an app to opt-out. Therefore I propose the following:
If an app really wants to use a persistent store it should create a key in the form [nc prefix][preserve keyword][app name]
(e.g. nc:preserve:ojsxc
) with the prefix it is using (e.g. ojsxc:
). Nextcloud could now search for those entries and preserve them. An implementation could look like the following:
let preservePrefixes = Object.keys(localStorage).filter(key => key.startsWith('nc:preserve:')).map(key => localStorage.getItem(key));
let regex = new Regex('^(' + preservePrefixes.join('|') + ')');
Object.keys(localStorage).forEach(key => !regex.test(key) ? localStorage.removeItem(key) : null);
That would be maybe slightly slower, but it's easy to implement and it doesn't require to change any app code.
from nextcloud-browser-storage.
This was probably the intention when those interfaces were specified.
Only partly true because a Nextcloud session can live longer than a browser session due to the remember-me feature.
An implementation could look like the following:
Yes, just like I implemented it here https://github.com/nextcloud/nextcloud-browser-storage/pull/2/files#diff-ce25cc9fe753b7439e6c13a3a30df75cR30-R34. This only clears the values saved through the abstraction.
from nextcloud-browser-storage.
Only partly true because a Nextcloud session can live longer than a browser session due to the remember-me feature.
I didn't consider that. You are right.
from nextcloud-browser-storage.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nextcloud-browser-storage.