4
2
mirror of https://github.com/getbible/app.git synced 2024-12-21 23:48:53 +00:00

tested, Debugged and fixed the error with state.selected actions and mutations

This commit is contained in:
Erastus Amunwe 2020-11-02 21:51:50 +02:00
parent 17a111d2dd
commit 97521c901d
2 changed files with 27 additions and 10 deletions

View File

@ -11,6 +11,7 @@ export default {
// putObj: {}
// }
// }
commit('toggle_loading', true)
const response = await getbible.get_translation(payload.abbreviation).catch(err => console.log(err))
// console.log(response);
if(!response) return;
@ -39,6 +40,7 @@ export default {
if(!success) return;
commit('add_translation', payload);
commit('toggle_loading', false)
},
async remove({commit}, payload){
// payload example
@ -52,6 +54,7 @@ export default {
// keyPath: "askjv"
// }
// }
commit('toggle_loading', true)
const {translation, saved_translations} = payload
let success = false
//save translation in indexdb
@ -67,8 +70,12 @@ export default {
if(!success) return;
commit('REMOVE_TRANSLATION', payload);
setTimeout(()=>{
commit('toggle_loading', false)
}, 1200)
},
async initialise({commit}){
commit('toggle_loading', true)
let saved_translations = await idb.getAll('saved_translations').catch(err => console.log(err));
if(!saved_translations) saved_translations = [];
@ -80,7 +87,7 @@ export default {
commit('initialise', {saved_translations, translation: translations[0]})
commit('toggle_loading', false)
},
set_chapter({commit}, payload) {
@ -90,10 +97,15 @@ export default {
commit('set_book', payload)
},
async set_translation({commit}, payload){
commit('toggle_loading', true)
let translation = await idb.get('translations', payload.selected_translation).catch(err => console.log(err));
if(!translation) return;
payload.translation = translation
commit('set_translation', payload)
// console.log("from acitons", payload);
setTimeout(()=>{
commit('toggle_loading', false)
}, 2500)
}
}

View File

@ -1,3 +1,5 @@
export default {
add_translation (state, payload ) {
@ -52,20 +54,23 @@ export default {
// state.search = search
// }
initialise(state, payload){
state.saved_translations = payload.saved_translations
state.in_memory_translation = payload.translation
state.saved_translations = payload.saved_translations
state.in_memory_translation = payload.translation
},
set_chapter(state, payload){
state.selected.chapter = payload;
state.selected.chapter = payload;
},
set_book(state, payload){
state.selected.chapter = null;
state.selected.book = payload;
state.selected.chapter = null;
state.selected.book = payload;
},
set_translation(state, payload){
state.selected.book = null
state.selected.chapter = null
state.selected.translation = payload.selected_translation;
state.in_memory_translation = payload.translation;
state.selected.book = null
state.selected.chapter = null
state.selected.translation = payload.selected_translation;
state.in_memory_translation = payload.translation;
},
toggle_loading(state, payload){
state.loading = payload;
}
}