added 260907 version of worker toolkit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
const {
|
||||
get,
|
||||
Component,
|
||||
getProperties,
|
||||
} = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ['emoji-reactions'],
|
||||
|
||||
actions: {
|
||||
onEmojiSelect(emojiTitle) {
|
||||
let reactions = get(this, 'reactable.reactions');
|
||||
const existentReaction = reactions.findBy('value', emojiTitle);
|
||||
|
||||
if (existentReaction && get(existentReaction, 'participated')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { reactable, store } = getProperties(this, 'reactable', 'store');
|
||||
|
||||
let record = existentReaction || store.createRecord('reaction', {
|
||||
value: emojiTitle,
|
||||
reactable_id: get(reactable, 'id'),
|
||||
reactable_type: get(reactable, 'modelType'),
|
||||
});
|
||||
|
||||
record
|
||||
.save()
|
||||
.then(reaction => {
|
||||
if (!existentReaction) {
|
||||
reactions.pushObject(reaction);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user