From 296f77df6fe48d30ce7a62985be4ab3f4984c215 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Fri, 10 Feb 2017 14:13:45 -0600 Subject: [PATCH] only accept relevant items --- .../app/services/directives/views/accountMenu.js | 2 +- app/assets/javascripts/app/services/modelManager.js | 9 +++++++-- .../templates/frontend/directives/account-menu.html.haml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/services/directives/views/accountMenu.js b/app/assets/javascripts/app/services/directives/views/accountMenu.js index bf54654f8..088b98969 100644 --- a/app/assets/javascripts/app/services/directives/views/accountMenu.js +++ b/app/assets/javascripts/app/services/directives/views/accountMenu.js @@ -71,7 +71,7 @@ class AccountMenu { } $scope.newPasswordData.status = "Successfully changed password and re-encrypted all items."; $timeout(function(){ - alert("Your password has been changed, and your items successfully re-encrypted and synced. You must sign out on all other signed in applications and sign in again, or else you may corrupt your data.") + alert("Your password has been changed, and your items successfully re-encrypted and synced. You must sign out of all other signed in applications and sign in again, or else you may corrupt your data.") $scope.newPasswordData = {}; }, 1000) }); diff --git a/app/assets/javascripts/app/services/modelManager.js b/app/assets/javascripts/app/services/modelManager.js index 1d920c018..8b23060dc 100644 --- a/app/assets/javascripts/app/services/modelManager.js +++ b/app/assets/javascripts/app/services/modelManager.js @@ -8,6 +8,7 @@ class ModelManager { this.itemChangeObservers = []; this.items = []; this._extensions = []; + this.acceptableContentTypes = ["Note", "Tag", "Extension"]; } get allItems() { @@ -62,7 +63,7 @@ class ModelManager { for (var json_obj of items) { json_obj = _.omit(json_obj, omitFields || []) var item = this.findItem(json_obj["uuid"]); - if(json_obj["deleted"] == true) { + if(json_obj["deleted"] == true || !_.includes(this.acceptableContentTypes, json_obj["content_type"])) { if(item) { this.removeItemLocally(item) } @@ -227,7 +228,11 @@ class ModelManager { /* Used when changing encryption key */ setAllItemsDirty() { - for(var item of this.allItems) { + var relevantItems = this.allItems.filter(function(item){ + return _.includes(this.acceptableContentTypes, item.content_type); + }.bind(this)); + + for(var item of relevantItems) { item.setDirty(true); } } diff --git a/app/assets/templates/frontend/directives/account-menu.html.haml b/app/assets/templates/frontend/directives/account-menu.html.haml index a1e03cd1e..6927bff0f 100644 --- a/app/assets/templates/frontend/directives/account-menu.html.haml +++ b/app/assets/templates/frontend/directives/account-menu.html.haml @@ -47,7 +47,7 @@ %a.block.mt-5{"ng-click" => "newPasswordData.changePassword = !newPasswordData.changePassword"} Change Password %section.gray-bg.mt-10.medium-padding{"ng-if" => "newPasswordData.changePassword"} %p.bold Change Password (Beta) - %p.mt-10 Since your encrpytion key is based on your password, changing your password requires all your notes and tags to be re-encrypted using your new key. + %p.mt-10 Since your encryption key is based on your password, changing your password requires all your notes and tags to be re-encrypted using your new key. %p.mt-5 If you have thousands of items, this can take several minutes — you must keep the application window open during this process. %p.mt-5 After changing your password, you must log out of all other applications currently signed in to your account. %p.bold.mt-5 It is highly recommended you download a backup of your data before proceeding.