Sync local cloud variable changes across local windows

closes #183
This commit is contained in:
Thomas Weber committed 2021-10-06 19:08:56 -05:00
1 parent 3988329b93
commit cf483f214e
1 file changed
+8
+8
View File
@@ -185,6 +185,7 @@ class LocalStorageProvider {
constructor (key='p4:cloudvariables') {
this.key = key;
this.variables = {};
this.handleStorageEvent = this.handleStorageEvent.bind(this);
}
readFromLocalStorage () {
@@ -211,8 +212,15 @@ class LocalStorageProvider {
}
}
handleStorageEvent (e) {
if (e.key === this.key && e.storageArea === localStorage) {
this.readFromLocalStorage();
}
}
enable () {
this.readFromLocalStorage();
window.addEventListener('storage', this.handleStorageEvent);
}
handleUpdateVariable (name, value) {