1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-12 18:28:03 +01:00
Pinafore-Web-Client-Frontend/routes/_store/mixins/instanceMixins.js
2018-03-04 16:27:15 -08:00

27 lines
975 B
JavaScript

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