diff --git a/app/assets/javascripts/app/services/singletonManager.js b/app/assets/javascripts/app/services/singletonManager.js index ddee5b64a..6c4ce588b 100644 --- a/app/assets/javascripts/app/services/singletonManager.js +++ b/app/assets/javascripts/app/services/singletonManager.js @@ -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.