Refactor nav component so that it only displays books for which we have data
This commit is contained in:
parent
b95c6510d4
commit
73400d8a66
|
@ -17,30 +17,23 @@ export default class ScriptureNavBarComponent extends Component {
|
|||
constructor(...args) {
|
||||
super(...args);
|
||||
console.log(books);
|
||||
this.books = this.availableBooks;
|
||||
this.books = this.getBooks();
|
||||
// console.log(this.books);
|
||||
}
|
||||
|
||||
// get only the books that we have backend data for
|
||||
get
|
||||
availableBooks()
|
||||
async getBooks()
|
||||
{
|
||||
return this.store.findAll('book').then(function(backendBooks) {
|
||||
let available = [];
|
||||
backendBooks.forEach(
|
||||
value => {
|
||||
let foundValue = books.find(function(book) {
|
||||
return book['name'] == value.id
|
||||
const results = await this.store.findAll('book');
|
||||
|
||||
this.books = results.map((book) => {
|
||||
let foundValue = books.find(function(value) {
|
||||
return value['name'] == book.id
|
||||
});
|
||||
if(foundValue) {
|
||||
available.push(foundValue);
|
||||
return foundValue;
|
||||
}
|
||||
});
|
||||
return available;
|
||||
}).then(function(response) {
|
||||
console.log(response);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
Loading…
Reference in New Issue