mirror of
https://github.com/getbible/app.git
synced 2024-12-22 07:48:55 +00:00
tested, Debugged and fixed the error with state.selected actions and mutations
This commit is contained in:
parent
17a111d2dd
commit
97521c901d
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
add_translation (state, payload ) {
|
add_translation (state, payload ) {
|
||||||
|
|
||||||
@ -52,20 +54,23 @@ export default {
|
|||||||
// state.search = search
|
// state.search = search
|
||||||
// }
|
// }
|
||||||
initialise(state, payload){
|
initialise(state, payload){
|
||||||
state.saved_translations = payload.saved_translations
|
state.saved_translations = payload.saved_translations
|
||||||
state.in_memory_translation = payload.translation
|
state.in_memory_translation = payload.translation
|
||||||
},
|
},
|
||||||
set_chapter(state, payload){
|
set_chapter(state, payload){
|
||||||
state.selected.chapter = payload;
|
state.selected.chapter = payload;
|
||||||
},
|
},
|
||||||
set_book(state, payload){
|
set_book(state, payload){
|
||||||
state.selected.chapter = null;
|
state.selected.chapter = null;
|
||||||
state.selected.book = payload;
|
state.selected.book = payload;
|
||||||
},
|
},
|
||||||
set_translation(state, payload){
|
set_translation(state, payload){
|
||||||
state.selected.book = null
|
state.selected.book = null
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user