4
2
mirror of https://github.com/getbible/app.git synced 2024-12-22 15:58:55 +00:00

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

View File

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