4
2
mirror of https://github.com/getbible/app.git synced 2024-06-17 09:42:22 +00:00

refactored some codes

This commit is contained in:
Erastus Amunwe 2020-10-26 15:23:01 +02:00
parent 79e27f0edb
commit 098026e360

View File

@ -84,8 +84,8 @@ export default {
return this.filteredChapters
},
filteredChapters() {
return _.orderBy(this.chapter.verses.filter((item) => item.verse.toString().toLowerCase()
.includes(this.search.toLowerCase())
return _.orderBy(this.chapter.verses.filter((item) =>
item.verse.toString().toLowerCase().includes(this.search.toLowerCase())
|| item.chapter.toString().toLowerCase().includes(this.search.toLowerCase())
|| item.name.toString().toLowerCase().includes(this.search.toLowerCase())
|| item.text.toLowerCase().includes(this.search.toLowerCase())), 'verse');
@ -99,22 +99,30 @@ export default {
headers: {'Access-Control-Allow-Origin': '*'}
};
fetch(`https://getbible.net/v2/${this.translation}/${this.book}/${this.chapter_num}.json`, config)
.then(response => {
this.progress = 99
return response.json()})
.then(data => {
this.loading =false
let url = `https://getbible.net/v2/${this.translation}/${this.book}/${this.chapter_num}.json`
// console.log(data)
this.chapter = data
this.progress =0
}).catch(function(err) {
let response = fetch(url, config).catch(function(err) {
this.chapter = err
this.loading =false
this.message = 'Error'
});
if (!response) return;
this.progress = 99
let data = response.json().catch(err => {
this.chapter = err
this.loading =false
this.message = 'Error'
})
this.loading =false
if (!data) return;
this.chapter = data
this.progress =0
},
async update_tr(){
@ -126,7 +134,8 @@ export default {
this.loading =true
this.progress =25
this.message = 'Loading...'
fetch(`https://getbible.net/v2/${this.translation}/books.json`,config)
let url = `https://getbible.net/v2/${this.translation}/books.json`
fetch(url,config)
.then(response => response.json())
.then(data => {
// console.log(data)