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

View File

@ -1,3 +1,5 @@
export default { export default {
add_translation (state, payload ) { add_translation (state, payload ) {
@ -67,5 +69,8 @@ export default {
state.selected.chapter = null state.selected.chapter = null
state.selected.translation = payload.selected_translation; state.selected.translation = payload.selected_translation;
state.in_memory_translation = payload.translation; state.in_memory_translation = payload.translation;
},
toggle_loading(state, payload){
state.loading = payload;
} }
} }