Skip to content

Commit

Permalink
feature/character-list — very light refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandat committed May 14, 2016
1 parent e7e4062 commit f9c7de4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/character/list/character-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
vm.characters = [];
vm.searching = false;
vm.offset = 0;
vm.hasMoreData = false;
vm.hasMore = false;
vm.toggleFave = toggleFave;
vm.search = search;
vm.loadMore = loadMore;
vm.showMore = showMore;

var listeners = [];
var faves = favouriteService.faves;
Expand All @@ -39,7 +39,7 @@
showSpinner();
var promise = characterService.findByName(vm.filter);
vm.characters = [];
vm.hasMoreData = false;
vm.hasMore = false;
vm.offset = 0;
$cordovaKeyboard.close();
return promise
Expand All @@ -63,7 +63,7 @@
vm.searching = false;
}

function loadMore() {
function showMore() {
showSpinner();
vm.offset += defaultOffset;
return characterService.findByName(vm.filter, vm.offset)
Expand All @@ -81,7 +81,7 @@
// Update meta
meta = vm.characters.meta = results.meta;
// Update boolean to know instantly if there is more
vm.hasMoreData = meta && (meta.count + meta.offset) < meta.total;
vm.hasMore = meta && (meta.count + meta.offset) < meta.total;
}

// Event handler called when clicking the fave button (heart).
Expand Down
2 changes: 1 addition & 1 deletion app/character/list/character-list.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ ion-view.characters(view-title='Characters')
| {{::character.name}}
.characters__footer
ion-spinner(ng-if='vm.searching')
button.button.button-block.button-assertive.characters__show-more(ng-click='vm.loadMore()' ng-show='vm.hasMoreData')
button.button.button-block.button-assertive.characters__show-more(ng-click='vm.showMore()' ng-show='vm.hasMore')
| Show more

0 comments on commit f9c7de4

Please sign in to comment.