4
2
Fork 0

Added new getters and debugged all getters, also added a loading var to state

This commit is contained in:
Erastus Amunwe 2020-11-03 13:12:55 +02:00
parent 2f84e963c8
commit c71a1214fc
2 changed files with 18 additions and 8 deletions

View File

@ -1,3 +1,5 @@
export default {
chapter : (state) =>{
@ -7,7 +9,9 @@ export default {
book_nr : (state) =>{
return state.selected.book
},
loading: (state) =>{
return state.loading;
},
book_name:(state, getters)=> {
return getters.books.find(book => book.nr === getters.book_nr).name
},
@ -17,29 +21,34 @@ export default {
},
in_memory_translation : (state) =>{
// console.log("from ", state.in_memory_translation );
return state.in_memory_translation
},
books : (state)=>{
if(!state.in_memory_translation.books)
books : (state, getters)=>{
if(!getters.in_memory_translation.books)
return []
return state.in_memory_translation.books.map(book => ({nr: book.nr, name: book.name}))
return getters.in_memory_translation.books.map(book => ({nr: book.nr, name: book.name}))
},
dir:(state, getters)=>{
if(getters.in_memory_translation.dir)
return getters.in_memory_translation.dir.toLowerCase();
// console.log(getters.in_memory_translation);
if(!getters.in_memory_translation.direction)
return 'ltr'
return getters.in_memory_translation.direction.toLowerCase();
},
chapters : (state, getters) =>{
if(!getters.book) return [];
const book = getters.books.find(book => book.nr === getters.book)
console.log(getters.book_nr);
if(!getters.book_nr) return [];
const book = getters.in_memory_translation.books.find(book => book.nr == getters.book_nr)
console.log("Found the book",book);
return book.chapters
},
verses: (state, getters) => {
// console.log("Searching for chapter", getters.chapter);
if(!getters.chapter)
return []
const chapter = getters.chapters.find(chapter => chapter.chapter === getters.chapter)

View File

@ -7,6 +7,7 @@ export default {
book: null,
chapter: null
},
loading: false,
in_memory_translation:{},
search: '',
}