From ab963f45676e31733407ba24b43aac8ec8251945 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Thu, 12 Oct 2017 11:07:04 +0530 Subject: [PATCH] SEARCH-273 - Changed the encryption to async - Logged decryption time --- demo/search.html | 4 +++- js/search/search.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/demo/search.html b/demo/search.html index b70b44fd..eccdc578 100644 --- a/demo/search.html +++ b/demo/search.html @@ -200,7 +200,9 @@ merge.addEventListener('click', function () { search.mergeIndexBatches().then(function () { - search.encryptIndex(); + search.encryptIndex().then(function () { + resultsEl.innerHTML = "Merging and Encrypting index completed" + }); }).catch(function (err) { resultsEl.innerHTML = 'Error: ' + err; }); diff --git a/js/search/search.js b/js/search/search.js index 4505f95e..72b58afa 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -54,6 +54,7 @@ class Search { * @param key */ constructor(userId, key) { + console.time('Decrypting'); this.isInitialized = false; this.userId = userId; this.key = key; @@ -68,6 +69,7 @@ class Search { decryptAndInit() { this.crypto.decryption().then(() => { + console.timeEnd('Decrypting'); this.init(); }).catch(() => { this.init(); @@ -206,10 +208,10 @@ class Search { * to the main user index */ encryptIndex() { - this.crypto.encryption().then(() => { + return this.crypto.encryption().then(() => { return 'Success' }).catch((e) => { - throw new Error(e) + return (new Error(e)); }); }