From 5591077fe9241def5fa33fc90a24681c8b7b0976 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 23 Feb 2016 14:07:53 +0100 Subject: repurchase detection --- extension/lib/wallet/query.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'extension/lib/wallet/query.ts') diff --git a/extension/lib/wallet/query.ts b/extension/lib/wallet/query.ts index b82c85189..62411dab3 100644 --- a/extension/lib/wallet/query.ts +++ b/extension/lib/wallet/query.ts @@ -287,6 +287,29 @@ class QueryRoot { .then(() => promise); } + /** + * Get one object from a store by its key. + */ + getIndexed(storeName, indexName, key): Promise { + if (key === void 0) { + throw Error("key must not be undefined"); + } + + const {resolve, promise} = openPromise(); + + const doGetIndexed = (tx) => { + const req = tx.objectStore(storeName).index(indexName).get(key); + req.onsuccess = (r) => { + resolve(req.result); + }; + }; + + this.addWork(doGetIndexed, storeName, false); + return Promise.resolve() + .then(() => this.finish()) + .then(() => promise); + } + /** * Finish the query, and start the query in the first place if necessary. */ -- cgit v1.2.3