From 0317830b12eb50e40c145417621c006829a19ac8 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 1 Feb 2017 09:48:56 +0000 Subject: [PATCH] Check for a deserialize() function --- src/store/indexeddb.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/store/indexeddb.js b/src/store/indexeddb.js index ee35aacd8..9f01b1a17 100644 --- a/src/store/indexeddb.js +++ b/src/store/indexeddb.js @@ -122,9 +122,13 @@ IndexedDBStoreBackend.prototype = { const txn = this.db.transaction(["users"], "readonly"); const store = txn.objectStore("users"); return selectQuery(store, undefined, (cursor) => { - const user = new User(cursor.value.userId); - Object.assign(user, cursor.value); - return user; + if (typeof User.deserialize === "function") { + return User.deserialize(cursor.value); + } else { + const user = new User(cursor.value.userId); + Object.assign(user, cursor.value); + return user; + } }); }); },