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

added idexdb to vuex action

This commit is contained in:
Erastus Amunwe 2020-10-27 22:36:27 +02:00
parent 302105c45a
commit 954b807595

View File

@ -1,10 +1,13 @@
import { createStore } from 'vuex'
import idb from './api/idb';
export const store = createStore({
state: {
settings: {
savedTr: []
},
trs: [],
search: '',
},
mutations: {
@ -14,6 +17,10 @@ export const store = createStore({
remove_translation (state,abbr ) {
state.settings.savedTr = state.settings.savedTr.filter(tr => tr.abbreviation !==abbr)
},
set_settings(state, settings){
state.settings = settings;
localStorage.setItem('settings', JSON.stringify(settings))
},
add_search(state, search){
state.search = search
@ -29,6 +36,24 @@ export const store = createStore({
add_s({commit}, sr){
commit('add_search', sr);
},
async deleteTranslation(context, tr) {
await idb.deleteCat(tr);
},
async getTranslations(context) {
context.state.trs = [];
let trs = await idb.getTranslations();
trs.forEach(t => {
context.state.trs.push(t);
});
},
async getTranslation(context, abbr) {
let tr = await idb.getTranslation(abbr);
return tr;
},
async saveTranslation(context, tr) {
await idb.saveCat(tr);
}
}
})