Skip to content
Snippets Groups Projects
Commit 1226d3b2 authored by Adam Procter's avatar Adam Procter
Browse files

added other nodes live sync now working

parent fbb6a6dc
No related branches found
No related tags found
No related merge requests found
<template>
<div v-for="(nodes, index) in otherArray" :key="index">
<p
class="readmode"
:id="nodes.node_id"
:inner-html.prop="nodes.node_text"
></p>
<div v-for="(nodes, index) in otherNodes.otherNodes" :key="index">
<p class="readmode" :id="nodes.id">
{{ nodes.text }}
</p>
</div>
</template>
......@@ -17,45 +15,20 @@ import { mapState } from 'vuex'
export default {
name: 'OtherNodes',
data() {
return {
otherArray: [],
}
},
computed: {
...mapState({
otherNodes: (state) => state.otherNodes,
}),
},
// watch: {
// added: function () {
// this.loadData()
// },
// },
mounted() {
//console.log('mounted')
this.$store.dispatch('getOthernodes')
setTimeout(this.loadData, 500)
// if (localStorage.nogg_microcosm) {
// // var devicename = localStorage.nogg_name
// var microcosm = localStorage.nogg_microcosm
// this.$store.dispatch('setMicrocosm', { microcosm })
// } else {
// console.log('no')
// // go home
// }
},
methods: {
loadData() {
var othersFiltered = this.otherNodes.otherNodes.filter(
(nodes) => nodes.node_deleted == false
)
this.$store.dispatch('getOthernodes')
this.otherArray = othersFiltered
this.$store.dispatch('setOthernodes')
},
},
}
......
var pouchdb
// PRETTY SURE this is wrong
import * as store from '@/store/store.js'
var deviceName
export const state = {
allNodes: [],
......@@ -17,8 +15,7 @@ export const mutations = {
})
.then(function (doc) {
state.allNodes = doc.rows
// TODO: THIS IS NOT working
store.commit('SET_OTHER_NODES')
console.log('get all nodes')
})
.catch(function (err) {
console.log(err)
......@@ -26,11 +23,13 @@ export const mutations = {
},
SET_OTHER_NODES(state) {
console.log('setting')
state.otherNodes = []
var i
var j
for (i = 0; i < Object.keys(state.allNodes).length; i++) {
if (state.allNodes[i].id != deviceName) {
for (j = 0; j < Object.keys(state.allNodes[i].doc.nodes).length; j++) {
const newNode = {
id: state.allNodes[i].doc.nodes[j].node_id,
......@@ -41,15 +40,22 @@ export const mutations = {
state.otherNodes.push(newNode)
}
}
}
},
}
export const actions = {
getOthernodes: ({ commit }) => {
commit('GET_ALL_NODES')
commit('SET_OTHER_NODES')
},
setOthernodes: ({ commit }) => {
commit('SET_OTHER_NODES')
},
getMicrocosm(vuexContext) {
deviceName = vuexContext.rootState.setup.deviceName
pouchdb = vuexContext.rootState.setup.pouchdb
},
}
......
......@@ -79,8 +79,7 @@ export const actions = {
retry: true,
})
.on('change', function () {
// console.log('change happened')
// vuexContext.dispatch('getNodes', null, { root: true })
vuexContext.dispatch('getOthernodes', null, { root: true })
})
.on('paused', function () {})
.on('active', function () {
......
<template>
<ToolBar @added-node="addedNode" />
<MyNodes :added="added" />
<OtherNodes />
<MyNodes :added="added" />
</template>
<script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment