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) {
|
constructor(...args) {
|
||||||
super(...args);
|
super(...args);
|
||||||
console.log(books);
|
console.log(books);
|
||||||
this.books = this.availableBooks;
|
this.books = this.getBooks();
|
||||||
// console.log(this.books);
|
// console.log(this.books);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get only the books that we have backend data for
|
// get only the books that we have backend data for
|
||||||
get
|
async getBooks()
|
||||||
availableBooks()
|
|
||||||
{
|
{
|
||||||
return this.store.findAll('book').then(function(backendBooks) {
|
const results = await this.store.findAll('book');
|
||||||
let available = [];
|
|
||||||
backendBooks.forEach(
|
this.books = results.map((book) => {
|
||||||
value => {
|
let foundValue = books.find(function(value) {
|
||||||
let foundValue = books.find(function(book) {
|
return value['name'] == book.id
|
||||||
return book['name'] == value.id
|
|
||||||
});
|
});
|
||||||
if(foundValue) {
|
if(foundValue) {
|
||||||
available.push(foundValue);
|
return foundValue;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return available;
|
|
||||||
}).then(function(response) {
|
|
||||||
console.log(response);
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
Loading…
Reference in New Issue