diff --git a/src/components/MyNodes.vue b/src/components/MyNodes.vue index 7e3e5ffc37e2ec54fa4db4d30b520ecd01411666..429687a0a9fceff7a58491c761a892ad48571772 100644 --- a/src/components/MyNodes.vue +++ b/src/components/MyNodes.vue @@ -25,6 +25,7 @@ <script> // @ is an alias to /src import { mapState } from 'vuex' + // import marked from 'marked' export default { @@ -42,6 +43,7 @@ export default { computed: { ...mapState({ + // TODO: Can you filter here instead ? myNodes: (state) => state.myNodes, }), @@ -54,6 +56,7 @@ export default { mounted() { setTimeout(this.loadData, 500) + //console.log(this.microcosmName.microcosmName) // NOT SURE THIS IS DOING ANYTHING ??? // const unwatch = this.$watch('nodesFiltered', (value) => { // this.$options.myArray = this.nodesFiltered @@ -70,7 +73,6 @@ export default { added: { deep: true, handler() { - console.log('add happened') setTimeout(this.loadData, 500) }, }, @@ -78,10 +80,10 @@ export default { methods: { loadData() { - console.log('loading data') + // console.log('loading data') this.myArray = this.nodesFiltered - console.log(this.myArray) - this.$forceUpdate() + // console.log(this.myArray) + // this.$forceUpdate() }, editNode(e) { diff --git a/src/store/modules/mynodes.js b/src/store/modules/mynodes.js index ff2fb5000e562d0364a158535e30d5c895262237..5ae758bf3856b76af0285dff799438c775e9e4bb 100644 --- a/src/store/modules/mynodes.js +++ b/src/store/modules/mynodes.js @@ -1,9 +1,13 @@ var pouchdb var deviceName +//var microcosmName +// var e export const state = { myNodes: [], activeNode: {}, + lastMicrocosm: '', + lastdeviceName: '', } export const mutations = { @@ -51,6 +55,7 @@ export const mutations = { }) }) .catch(function (err) { + // TODO: Does this situation ever hit 404 ? console.log(err) if (err.status == 404) { var uniqueid = @@ -75,7 +80,7 @@ export const mutations = { } }) }, - GET_NODES() { + GET_MY_NODES() { // console.log('called ' + deviceName) pouchdb .get(deviceName) @@ -88,9 +93,10 @@ export const mutations = { .catch(function (err) { console.log(err) }) - // TODO: Get other nodes from all other devices }, + // TODO: Get other nodes from all other devices + EDIT_NODE(state, e) { var i for (i = 0; i < Object.keys(state.myNodes).length; i++) { @@ -130,9 +136,8 @@ export const actions = { commit('ADD_NODE', e) }, - getNodes: ({ commit }, e) => { - console.log('getting nodes as you added one') - commit('GET_NODES', e) + getMynodes: ({ commit }, e) => { + commit('GET_MY_NODES', e) }, editNode: ({ commit }, { nodeid, nodetext }) => { @@ -140,11 +145,20 @@ export const actions = { }, getMicrocosm(vuexContext) { - // var lastmicrocosm = localStorage.getItem('nogg_microcosm') - // pouchdb = new PouchDB(lastmicrocosm) - // deviceName = localStorage.getItem('nogg_name') - //vuexContext.dispatch('startDB', null, { root: true }) deviceName = vuexContext.rootState.setup.deviceName + // microcosmName = vuexContext.rootState.setup.microcosmName pouchdb = vuexContext.rootState.setup.pouchdb + + // if (deviceName == '') { + // vuexContext.dispatch('setMicrocosm', e, { root: true }) + // } else { + // // + // this.microcosm = microcosmName + // this.deviceName = deviceName + // e = (this.devicename, this.microcosm) + // // this.pouchdb = pouchdb + // } }, } + +export const getters = {} diff --git a/src/store/modules/setup.js b/src/store/modules/setup.js index dd9daf1c26e0e74b0946b049edabb61740b81077..c934ada258fc63a194e37c12ae1e715d6b072bc4 100644 --- a/src/store/modules/setup.js +++ b/src/store/modules/setup.js @@ -74,7 +74,7 @@ export const actions = { // } pouchdb.replicate.from(remote).on('complete', function () { // GET_MYNODES from myNodes.js ACTION - vuexContext.dispatch('getNodes', null, { root: true }) + vuexContext.dispatch('getMynodes', null, { root: true }) pouchdb .sync(state.remoteAddress, { live: true, @@ -82,12 +82,12 @@ export const actions = { retry: true, }) .on('change', function () { - console.log('change happened') - vuexContext.dispatch('getNodes', null, { root: true }) + // console.log('change happened') + // vuexContext.dispatch('getNodes', null, { root: true }) }) .on('paused', function () {}) .on('active', function () { - vuexContext.dispatch('getNodes', null, { root: true }) + // vuexContext.dispatch('getNodes', null, { root: true }) }) .on('denied', function () {}) .on('complete', function () {}) @@ -97,3 +97,4 @@ export const actions = { }) }, } +export const getters = {}