Commit 026c457b authored by Adam Procter's avatar Adam Procter
Browse files

fixed initial node creation to work as expected

parent dfb48b03
......@@ -53,7 +53,8 @@ export default {
watch: {
added: function () {
this.loadData()
setTimeout(this.loadData, 500)
},
},
......@@ -72,13 +73,21 @@ export default {
},
methods: {
emptyData() {
if (this.myNodes.myNodes == 0) {
/// that
} else {
// this
}
},
loadData() {
var nodesFiltered = this.myNodes.myNodes.filter(
(nodes) => nodes.node_deleted == false
)
this.$store.dispatch('getMynodes')
this.myArray = nodesFiltered.reverse()
console.log(this.myArray.length)
// console.log(this.myArray.length)
},
editNode(e) {
......
......@@ -5,6 +5,7 @@
<button>Make Connections</button>
<UploadMedia />
<button @click="exitMicrocosm()">Exit</button>
<p>{{ microcosm }}</p>
</div>
</template>
......@@ -19,7 +20,13 @@ export default {
UploadMedia,
},
data() {
return {}
return {
microcosm: 'microcosm name',
}
},
mounted() {
this.microcosm = localStorage.getItem('nogg_microcosm')
},
mixins: [
......
......@@ -54,28 +54,45 @@ export const mutations = {
})
})
.catch(function (err) {
// TODO: Does this situation ever hit 404 ?
// console.log(err)
// HITS a 404 on very first node being created
if (err.status == 404) {
var uniqueid =
Math.random().toString(36).substring(2, 15) +
Math.random().toString(36).substring(2, 15)
pouchdb.put({
_id: deviceName,
nodes: [
{
node_id: uniqueid,
node_text: '',
node_owner: deviceName,
node_type: 'sheet',
node_shape: 'square',
node_deleted: false,
node_readmode: false,
node_color: '#9bc2d8',
},
],
})
pouchdb
.put({
_id: deviceName,
nodes: [
{
node_id: uniqueid,
node_text: '',
node_owner: deviceName,
node_type: 'sheet',
node_shape: 'square',
node_deleted: false,
node_readmode: false,
node_color: '#9bc2d8',
},
],
})
.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 = {
})
.then(function (doc) {
state.allNodes = doc.rows
console.log('get all nodes')
})
.catch(function (err) {
console.log(err)
......@@ -23,7 +23,6 @@ export const mutations = {
},
SET_OTHER_NODES(state) {
console.log('setting')
state.otherNodes = []
var i
var j
......
......@@ -11,6 +11,8 @@ import MyNodes from '@/components/MyNodes.vue'
export default {
mounted() {
this.$store.dispatch('getMicrocosm')
// register, i.e. in a `beforeDestroy` hook
window.addEventListener('unload', this.someMethod)
},
name: 'Collect',
......@@ -29,6 +31,14 @@ export default {
addedNode() {
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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment