From e75ff47198132757e0b0aa6f20fb41109f6d73b5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 9 Oct 2017 15:48:12 -0400 Subject: [PATCH] sync fixes --- localassetmanager.js | 2 ++ sync/itemrepository.js | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/localassetmanager.js b/localassetmanager.js index 97eeed5..48f9cd0 100644 --- a/localassetmanager.js +++ b/localassetmanager.js @@ -34,6 +34,8 @@ function getServerItems(serverId) { + console.log('[localassetmanager] Begin getServerItems'); + return itemrepository.getAll(serverId); } diff --git a/sync/itemrepository.js b/sync/itemrepository.js index b7f58c1..a7404df 100644 --- a/sync/itemrepository.js +++ b/sync/itemrepository.js @@ -16,7 +16,6 @@ function ServerDatabase(dbName, readyCallback) { - var instance = this; var request = indexedDB.open(dbName, dbVersion); request.onerror = function (event) { @@ -34,9 +33,14 @@ // Use transaction oncomplete to make sure the objectStore creation is // finished before adding data into it. objectStore.transaction.oncomplete = function (event) { - readyCallback(instance); + readyCallback(db); }; }; + + request.onsuccess = function (event) { + var db = event.target.result; + readyCallback(db); + }; } function getDbName(serverId) { @@ -50,6 +54,7 @@ var db = databases[dbName]; if (db) { callback(db); + return; } new ServerDatabase(dbName, function (db) {