bugfix for handling update

release-neutralino
HerrHase 2 years ago
parent 69c47483fb
commit 62f8124d1c

@ -72,7 +72,6 @@ class Connector {
// if event is in handlers-object mapped call it
if (this.handlers.hasOwnProperty(message.event)) {
console.log(event.data)
this.handlers[message.event].call(null, this, message.data)
}
}

@ -38,7 +38,7 @@ class AppsHandler {
appsStore.update(data)
.then((data) => {
connector.send('pouchdb.apps.readyOne', data)
connector.send('pouchdb.apps.success', data)
})
}
@ -72,6 +72,7 @@ class AppsHandler {
appsStore.find()
.then((data) => {
console.error('send result', data)
connector.send('pouchdb.apps.ready', data)
})
}

@ -30,7 +30,7 @@ class AppsStore extends PouchdbHandler {
create(data) {
return this.db.post(data)
.then((response) => {
return response
return this.findOneById(response._id)
}).catch((error) => {
console.log(error)
})
@ -43,10 +43,9 @@ class AppsStore extends PouchdbHandler {
*
*/
update(data) {
console.log(data)
return this.db.put(data)
.then((response) => {
return response
return this.findOneById(response._id)
}).catch((error) => {
console.log(error)
})
@ -82,7 +81,7 @@ class AppsStore extends PouchdbHandler {
return documents.docs[0]
}
}).catch((error) => {
console.log(error)
console.error(error)
})
}
@ -112,12 +111,12 @@ class AppsStore extends PouchdbHandler {
return this.db.find(query).then((documents) => {
if (documents.warning) {
console.log(documents.warning)
console.warning(documents.warning)
}
return documents.docs
}).catch((error) => {
console.log(error)
console.error(error)
})
}

@ -132,6 +132,8 @@
// adding event for open sidebar
formStore.on('open', (id) => {
this.reset()
// if id is send, load apps from pouchdb
if (id) {
Neutralino.extensions.dispatch('js.neutralino.pouchdb', 'pouchdb.apps.findOne', {
@ -166,6 +168,9 @@
appsStore.trigger('updated')
this.state.current._id = event.detail._id
this.state.current._rev = event.detail._rev
// stop loading
this.state.loading = false
this.update()
@ -174,9 +179,12 @@
// receive from extensions database
Neutralino.events.on('pouchdb.apps.readyOne', (event) => {
this.reset()
this.state.current = event.detail
if (!this.state.current.tags) {
this.state.current.tags = []
}
tagsStore.trigger('update', this.state.current.tags)
// stop loading
@ -232,10 +240,10 @@
data.thumbnail = this.state.current.thumbnail
// send to extensions database
if (data._id) {
Neutralino.extensions.dispatch('js.neutralino.pouchdb', 'pouchdb.apps.create', data)
} else {
if (data._id && data._rev) {
Neutralino.extensions.dispatch('js.neutralino.pouchdb', 'pouchdb.apps.update', data)
} else {
Neutralino.extensions.dispatch('js.neutralino.pouchdb', 'pouchdb.apps.create', data)
}
},
@ -279,6 +287,8 @@
this.state.current = {
}
tagsStore.trigger('update', [])
}
}
}

Loading…
Cancel
Save