pinafore/routes/_store/mixins/statusMixins.js
Nolan Lawson 8d5690d63d
remove get() with string from Svelte calls (#169)
* remove get() with string pt 1

* remove get() with string pt 2

* fix typo

* fix some null exceptions in get()

* fixup code style
2018-04-19 09:37:05 -07:00

23 lines
826 B
JavaScript

function getStatusModifications (store, instanceName) {
let { statusModifications } = store.get()
statusModifications[instanceName] = statusModifications[instanceName] || {
favorites: {},
reblogs: {}
}
return statusModifications
}
export function statusMixins (Store) {
Store.prototype.setStatusFavorited = function (instanceName, statusId, favorited) {
let statusModifications = getStatusModifications(this, instanceName)
statusModifications[instanceName].favorites[statusId] = favorited
this.set({statusModifications})
}
Store.prototype.setStatusReblogged = function (instanceName, statusId, reblogged) {
let statusModifications = getStatusModifications(this, instanceName)
statusModifications[instanceName].reblogs[statusId] = reblogged
this.set({statusModifications})
}
}