pinafore/routes/_store/mixins/instanceMixins.js

24 lines
871 B
JavaScript
Raw Normal View History

2018-03-03 22:15:50 +00:00
export function instanceMixins (Store) {
2018-03-03 22:51:48 +00:00
Store.prototype.setComposeData = function (realm, obj) {
let { composeData, currentInstance } = this.get()
let instanceNameData = composeData[currentInstance] = composeData[currentInstance] || {}
2018-03-03 22:51:48 +00:00
instanceNameData[realm] = Object.assign(instanceNameData[realm] || {}, obj)
this.set({ composeData })
2018-03-03 22:15:50 +00:00
}
Store.prototype.getComposeData = function (realm, key) {
let { composeData, currentInstance } = this.get()
return composeData[currentInstance] &&
composeData[currentInstance][realm] &&
composeData[currentInstance][realm][key]
2018-03-03 22:15:50 +00:00
}
2018-03-05 00:27:15 +00:00
Store.prototype.clearComposeData = function (realm) {
let { composeData, currentInstance } = this.get()
if (composeData && composeData[currentInstance]) {
delete composeData[currentInstance][realm]
2018-03-05 00:27:15 +00:00
}
this.set({ composeData })
2018-03-05 00:27:15 +00:00
}
2018-03-03 22:15:50 +00:00
}