Wait for initial data load before resolving singletons

This commit is contained in:
Mo Bitar
2018-12-20 10:17:34 -06:00
parent cb6f44da3a
commit 711fdc061c

View File

@@ -24,6 +24,7 @@ class SingletonManager {
$rootScope.$on("initial-data-loaded", (event, data) => {
this.resolveSingletons(modelManager.allItems, null, true);
this.initialDataLoaded = true;
})
/*
@@ -41,6 +42,11 @@ class SingletonManager {
})
$rootScope.$on("sync:completed", (event, data) => {
// Wait for initial data load before handling any sync. If we don't want for initial data load,
// then the singleton resolver won't have the proper items to work with to determine whether to resolve or create.
if(!this.initialDataLoaded) {
return;
}
// 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.