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

added getters

This commit is contained in:
Erastus Amunwe 2020-11-02 10:08:35 +02:00
parent 4e73b62c25
commit 2f677e6aea

49
src/store/getters.js Normal file
View File

@ -0,0 +1,49 @@
export default {
chapter : (state) =>{
return state.selected.chapter
},
book_nr : (state) =>{
return state.selected.book
},
book_name:(state, getters)=> {
return getters.books.find(book => book.nr === getters.book_nr).name
},
translation: (state)=>{
return state.selected.translation;
},
in_memory_translation : (state) =>{
return state.in_memory_translation
},
books : (state)=>{
if(!state.in_memory_translation.books)
return []
return state.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();
return 'ltr'
},
chapters : (state, getters) =>{
if(!getters.book) return [];
const book = getters.books.find(book => book.nr === getters.book)
return book.chapters
},
verses: (state, getters) => {
if(!getters.chapter)
return []
const chapter = getters.chapters.find(chapter => chapter.chapter === getters.chapter)
return chapter.verses;
}
}