Skip to content

Commit

Permalink
Rollback change that was too eager and broke things
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Mar 28, 2024
1 parent de691eb commit 42ecab1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/assets/javascripts/services/bookSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ angular.module('QuepidApp')
function bookSvc($http, broadcastSvc) {
this.books = [];
this.dropdownBooks = [];
this.booksCount = 0;

var Book = function(id, name) {
this.id = id;
Expand Down Expand Up @@ -135,20 +136,21 @@ angular.module('QuepidApp')
};

this.fetchDropdownBooks = function() {
this.dropdownBooks.length = 0;
var self = this;
self.dropdownBooks.length = 0;
return $http.get('api/dropdown/books')
.then(function(response) {
this.booksCount = response.data.books_count;
self.booksCount = response.data.books_count;

angular.forEach(response.data.books, function(dataBook) {
let book = this.constructFromData(dataBook);
let book = self.constructFromData(dataBook);

if(!contains(this.dropdownBooks, book)) {
this.dropdownBooks.push(book);
if(!contains(self.dropdownBooks, book)) {
self.dropdownBooks.push(book);
}
});

broadcastSvc.send('fetchedDropdownBooksList', this.dropdownBooks);
broadcastSvc.send('fetchedDropdownBooksList', self.dropdownBooks);
});
};
}
Expand Down

0 comments on commit 42ecab1

Please sign in to comment.