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

fixed initial node creation to work as expected

parent dfb48b03
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,8 @@ export default { ...@@ -53,7 +53,8 @@ export default {
watch: { watch: {
added: function () { added: function () {
this.loadData() setTimeout(this.loadData, 500)
}, },
}, },
...@@ -72,13 +73,21 @@ export default { ...@@ -72,13 +73,21 @@ export default {
}, },
methods: { methods: {
emptyData() {
if (this.myNodes.myNodes == 0) {
/// that
} else {
// this
}
},
loadData() { loadData() {
var nodesFiltered = this.myNodes.myNodes.filter( var nodesFiltered = this.myNodes.myNodes.filter(
(nodes) => nodes.node_deleted == false (nodes) => nodes.node_deleted == false
) )
this.$store.dispatch('getMynodes') this.$store.dispatch('getMynodes')
this.myArray = nodesFiltered.reverse() this.myArray = nodesFiltered.reverse()
console.log(this.myArray.length) // console.log(this.myArray.length)
}, },
editNode(e) { editNode(e) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<button>Make Connections</button> <button>Make Connections</button>
<UploadMedia /> <UploadMedia />
<button @click="exitMicrocosm()">Exit</button> <button @click="exitMicrocosm()">Exit</button>
<p>{{ microcosm }}</p>
</div> </div>
</template> </template>
...@@ -19,7 +20,13 @@ export default { ...@@ -19,7 +20,13 @@ export default {
UploadMedia, UploadMedia,
}, },
data() { data() {
return {} return {
microcosm: 'microcosm name',
}
},
mounted() {
this.microcosm = localStorage.getItem('nogg_microcosm')
}, },
mixins: [ mixins: [
......
...@@ -54,14 +54,14 @@ export const mutations = { ...@@ -54,14 +54,14 @@ export const mutations = {
}) })
}) })
.catch(function (err) { .catch(function (err) {
// TODO: Does this situation ever hit 404 ? // HITS a 404 on very first node being created
// console.log(err)
if (err.status == 404) { if (err.status == 404) {
var uniqueid = var uniqueid =
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) +
Math.random().toString(36).substring(2, 15) Math.random().toString(36).substring(2, 15)
pouchdb.put({ pouchdb
.put({
_id: deviceName, _id: deviceName,
nodes: [ nodes: [
{ {
...@@ -76,6 +76,23 @@ export const mutations = { ...@@ -76,6 +76,23 @@ export const mutations = {
}, },
], ],
}) })
.then(function () {
return pouchdb.get(deviceName).then(function (doc) {
state.myNodes = doc.nodes
var end = Object.keys(state.myNodes).length - 1
const newNode = {
nodeid: state.myNodes[end].node_id,
nodetext: state.myNodes[end].node_text,
}
// OLD CODE:
// this was to set quick focus on new nodes
// i think... need to check old code
state.activeNode = newNode
})
})
.catch(function (err) {
console.log(err)
})
} }
}) })
}, },
......
...@@ -15,7 +15,7 @@ export const mutations = { ...@@ -15,7 +15,7 @@ export const mutations = {
}) })
.then(function (doc) { .then(function (doc) {
state.allNodes = doc.rows state.allNodes = doc.rows
console.log('get all nodes')
}) })
.catch(function (err) { .catch(function (err) {
console.log(err) console.log(err)
...@@ -23,7 +23,6 @@ export const mutations = { ...@@ -23,7 +23,6 @@ export const mutations = {
}, },
SET_OTHER_NODES(state) { SET_OTHER_NODES(state) {
console.log('setting')
state.otherNodes = [] state.otherNodes = []
var i var i
var j var j
......
...@@ -11,6 +11,8 @@ import MyNodes from '@/components/MyNodes.vue' ...@@ -11,6 +11,8 @@ import MyNodes from '@/components/MyNodes.vue'
export default { export default {
mounted() { mounted() {
this.$store.dispatch('getMicrocosm') this.$store.dispatch('getMicrocosm')
// register, i.e. in a `beforeDestroy` hook
window.addEventListener('unload', this.someMethod)
}, },
name: 'Collect', name: 'Collect',
...@@ -29,6 +31,14 @@ export default { ...@@ -29,6 +31,14 @@ export default {
addedNode() { addedNode() {
this.added = !this.added this.added = !this.added
}, },
someMethod() {
localStorage.removeItem('nogg_microcosm')
localStorage.removeItem('nogg_name')
location.assign(
process.env.VUE_APP_HTTP + '://' + process.env.VUE_APP_URL + '/'
)
},
}, },
} }
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment