Singleton manager uuid change observer
This commit is contained in:
@@ -15,10 +15,6 @@ class AccountMenu {
|
||||
|
||||
$scope.formData = {mergeLocal: true, ephemeral: false};
|
||||
|
||||
// testing:
|
||||
// $scope.formData.status = "Generating Login Keys...";
|
||||
// $scope.formData.authenticating = true;
|
||||
|
||||
$scope.user = authManager.user;
|
||||
|
||||
syncManager.getServerURL().then((url) => {
|
||||
|
||||
@@ -124,7 +124,6 @@ class PrivilegesManager {
|
||||
if(!this.privileges.content.desktopPrivileges) {
|
||||
this.privileges.content.desktopPrivileges = {};
|
||||
}
|
||||
console.log("Resolved existing privs", resolvedSingleton.uuid);
|
||||
resolve(resolvedSingleton);
|
||||
}, (valueCallback) => {
|
||||
// Safe to create. Create and return object.
|
||||
@@ -133,7 +132,6 @@ class PrivilegesManager {
|
||||
privs.setDirty(true);
|
||||
this.$rootScope.sync();
|
||||
valueCallback(privs);
|
||||
console.log("Creating new privs", privs.uuid);
|
||||
resolve(privs);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,6 +26,20 @@ class SingletonManager {
|
||||
this.resolveSingletons(modelManager.allItems, null, true);
|
||||
})
|
||||
|
||||
/*
|
||||
If an item alternates its uuid on registration, singletonHandlers might need to update
|
||||
their local refernece to the object, since the object reference will change on uuid alternation
|
||||
*/
|
||||
modelManager.addModelUuidChangeObserver("singleton-manager", (oldModel, newModel) => {
|
||||
for(var handler of this.singletonHandlers) {
|
||||
if(handler.singleton && SFPredicate.ItemSatisfiesPredicates(newModel, handler.predicates)) {
|
||||
// Reference is now invalid, calling resolveSingleton should update it
|
||||
handler.singleton = null;
|
||||
this.resolveSingletons([newModel]);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$rootScope.$on("sync:completed", (event, data) => {
|
||||
// The reason we also need to consider savedItems in consolidating singletons is in case of sync conflicts,
|
||||
// a new item can be created, but is never processed through "retrievedItems" since it is only created locally then saved.
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -8969,9 +8969,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"standard-file-js": {
|
||||
"version": "0.3.20",
|
||||
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.20.tgz",
|
||||
"integrity": "sha512-KlJ3IbAaJDRVC8jKxHBi/LL80d8zIbL1nZqwbDmqif1XwDQpTb8BB7ejg5pzZExQKDRFeXLS0JDSeWGMD+Luhw==",
|
||||
"version": "0.3.21",
|
||||
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.21.tgz",
|
||||
"integrity": "sha512-MLic68jA/EPqmNHbI2qrQn3V6/ZgazzM7C4AD6o2mORu3ZrFk64K0FPIrpN4LuA8IJi3sOqOFKsp1/caVw0zrw==",
|
||||
"dev": true
|
||||
},
|
||||
"static-extend": {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"serve-static": "^1.13.2",
|
||||
"sn-models": "0.1.9",
|
||||
"sn-stylekit": "file:~/Desktop/sn/dev/stylekit",
|
||||
"standard-file-js": "0.3.20",
|
||||
"standard-file-js": "0.3.21",
|
||||
"grunt-shell": "^2.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user