From 3ee148803672b19118bab1fad4405099c8a584b7 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Wed, 24 May 2017 17:32:27 -0500 Subject: [PATCH] web updates --- app/js/compiled.js | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/app/js/compiled.js b/app/js/compiled.js index d22160e7..a59bc58c 100644 --- a/app/js/compiled.js +++ b/app/js/compiled.js @@ -35735,11 +35735,11 @@ angular.module('app.frontend').service('analyticsManager', AnalyticsManager); return domain; } - this.$get = function ($rootScope, httpManager, modelManager) { - return new AuthManager($rootScope, httpManager, modelManager); + this.$get = function ($rootScope, httpManager, modelManager, dbManager) { + return new AuthManager($rootScope, httpManager, modelManager, dbManager); }; - function AuthManager($rootScope, httpManager, modelManager) { + function AuthManager($rootScope, httpManager, modelManager, dbManager) { var userData = localStorage.getItem("user"); if (userData) { @@ -35769,7 +35769,11 @@ angular.module('app.frontend').service('analyticsManager', AnalyticsManager); }; this.keys = function () { - var keys = { mk: localStorage.getItem("mk") }; + var mk = localStorage.getItem("mk"); + if (!mk) { + return null; + } + var keys = { mk: mk }; if (!localStorage.getItem("encryptionKey")) { _.merge(keys, Neeto.crypto.generateKeysFromMasterKey(keys.mk)); localStorage.setItem("encryptionKey", keys.encryptionKey); @@ -35831,14 +35835,18 @@ angular.module('app.frontend').service('analyticsManager', AnalyticsManager); }; this.handleAuthResponse = function (response, email, url, authParams, mk, pw) { - if (url) { - localStorage.setItem("server", url); - } - localStorage.setItem("user", JSON.stringify(response.user)); - localStorage.setItem("auth_params", JSON.stringify(_.omit(authParams, ["pw_nonce"]))); - localStorage.setItem("mk", mk); - localStorage.setItem("pw", pw); - localStorage.setItem("jwt", response.token); + try { + if (url) { + localStorage.setItem("server", url); + } + localStorage.setItem("user", JSON.stringify(response.user)); + localStorage.setItem("auth_params", JSON.stringify(_.omit(authParams, ["pw_nonce"]))); + localStorage.setItem("mk", mk); + localStorage.setItem("pw", pw); + localStorage.setItem("jwt", response.token); + } catch (e) { + dbManager.displayOfflineAlert(); + } }; this.register = function (url, email, password, callback) { @@ -35887,6 +35895,14 @@ var DBManager = function () { } _createClass(DBManager, [{ + key: 'displayOfflineAlert', + value: function displayOfflineAlert() { + var message = "There was an issue loading your offline database. This could happen for two reasons:"; + message += "\n\n1. You're in a private window in your browser. We can't save your data without access to the local database. Please use a non-private window."; + message += "\n\n2. You have two windows of the app open at the same time. Please close any other app instances and reload the page."; + alert(message); + } + }, { key: 'openDatabase', value: function openDatabase(callback, onUgradeNeeded) { var request = window.indexedDB.open("standardnotes", 1); @@ -35895,13 +35911,13 @@ var DBManager = function () { if (event.target.errorCode) { alert("Offline database issue: " + event.target.errorCode); } else { - alert("There was an issue loading your offline database. This usually happens when you have two windows of the app open at the same time. Please close any other app instances and reload the page."); + this.displayOfflineAlert(); } console.error("Offline database issue:", event); if (callback) { callback(null); } - }; + }.bind(this); request.onsuccess = function (event) { var db = event.target.result;