Persist showArchived flag

This commit is contained in:
Mo Bitar
2017-10-16 10:10:59 -05:00
parent ddce77b8ca
commit 5987ac1aa4
2 changed files with 11 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ angular.module('app.frontend')
.controller('NotesCtrl', function (authManager, $timeout, $rootScope, modelManager, storageManager) {
this.sortBy = storageManager.getItem("sortBy") || "created_at";
this.showArchived = storageManager.getBooleanValue("showArchived") || false;
this.sortDescending = this.sortBy != "title";
$rootScope.$on("editorFocused", function(){
@@ -63,7 +64,7 @@ angular.module('app.frontend')
base += " title";
}
if(this.showArchived && !this.tag.archiveTag) {
if(this.showArchived && (!this.tag || !this.tag.archiveTag)) {
base += " | Including archived"
}
@@ -72,6 +73,7 @@ angular.module('app.frontend')
this.toggleShowArchived = function() {
this.showArchived = !this.showArchived;
storageManager.setBooleanValue("showArchived", this.showArchived);
}
this.tagDidChange = function(tag, oldTag) {

View File

@@ -111,6 +111,14 @@ class StorageManager {
return storage.getItem(key);
}
setBooleanValue(key, value, vault) {
this.setItem(key, JSON.stringify(value), vault);
}
getBooleanValue(key, vault) {
return JSON.parse(this.getItem(key, vault));
}
removeItem(key, vault) {
var storage = this.getVault(vault);
storage.removeItem(key);