Skip to content

Commit

Permalink
feature/comic-list — Save last search filter upon restart
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandat committed Aug 14, 2016
1 parent a5ac482 commit fb9e873
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/comic/list/comic-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
.controller('ComicListController', ComicListController);

function ComicListController($log, comicService, $cordovaToast, throwErr, defaultPageSize, favouriteService, $cordovaKeyboard,
$rootScope, $scope) {
$rootScope, $scope, localStorageService) {

var vm = this;
vm.title = 'ComicListController';
// Let's start with something cool ;)
vm.filter = 'son';
vm.filter = getFirstFilter();
vm.comics = [];
vm.searching = false;
vm.offset = 0;
Expand Down Expand Up @@ -52,6 +52,7 @@
///////////

function notify() {
localStorageService.set('lastComicFilter', vm.filter || '');
$cordovaToast.showShortBottom(vm.comics.meta.total + ' results');
}

Expand Down Expand Up @@ -133,6 +134,12 @@
}
}

function getFirstFilter() {
var lastFilter = localStorageService.get('lastComicFilter');
// First time ever, I like to start with something nice.
return lastFilter == null ? 'son' : lastFilter;
}

}

})();

0 comments on commit fb9e873

Please sign in to comment.