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

dived the four store propeties into separate files

This commit is contained in:
Erastus Amunwe 2020-11-02 10:10:16 +02:00
parent f80f015c0e
commit 74de917015
2 changed files with 14 additions and 60 deletions

View File

@ -1,60 +0,0 @@
import { createStore } from 'vuex'
import idb from './api/idb';
export const store = createStore({
state: {
settings: {
savedTr: []
},
trs: [],
search: '',
},
mutations: {
add_translation (state,translation ) {
state.settings.savedTr.push(translation)
},
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
}
},
actions:{
add({commit}, tr){
commit('add_translation', tr);
},
remove({commit}, abbr){
commit('remove_translation', abbr);
},
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);
}
}
})
// export default store;

14
src/store/store.js Normal file
View File

@ -0,0 +1,14 @@
import { createStore } from 'vuex'
import state from './state';
import getters from './getters';
import mutations from './mutations';
import actions from './actions'
export const store = createStore({
state,
getters,
mutations,
actions
})