pinafore/routes/_store/mixins/instanceMixins.js
greenkeeper[bot] 8dbc1b0503 Update standard to the latest version 🚀 (#519)
* chore(package): update standard to version 12.0.0

* package lock update

* fix eslint
2018-08-29 21:42:57 -07:00

24 lines
871 B
JavaScript

export function instanceMixins (Store) {
Store.prototype.setComposeData = function (realm, obj) {
let { composeData, currentInstance } = this.get()
let instanceNameData = composeData[currentInstance] = composeData[currentInstance] || {}
instanceNameData[realm] = Object.assign(instanceNameData[realm] || {}, obj)
this.set({ composeData })
}
Store.prototype.getComposeData = function (realm, key) {
let { composeData, currentInstance } = this.get()
return composeData[currentInstance] &&
composeData[currentInstance][realm] &&
composeData[currentInstance][realm][key]
}
Store.prototype.clearComposeData = function (realm) {
let { composeData, currentInstance } = this.get()
if (composeData && composeData[currentInstance]) {
delete composeData[currentInstance][realm]
}
this.set({ composeData })
}
}