[FIX] Reaction buttons not behaving properly (#18832)

pull/18932/head^2
gabriellsh 5 years ago committed by GitHub
parent 38fc10ff68
commit 2be1b79e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      app/reactions/client/init.js
  2. 8
      app/ui-message/client/message.html
  3. 19
      app/ui-message/client/message.js

@ -10,15 +10,27 @@ import { EmojiPicker } from '../../emoji';
import { tooltip } from '../../ui/client/components/tooltip';
Template.room.events({
'click .add-reaction, click [data-message-action="reaction-message"]'(event) {
'click .add-reaction'(event, instance) {
event.preventDefault();
event.stopPropagation();
const data = Blaze.getData(event.currentTarget);
const { msg: { rid, _id: mid } } = messageArgs(data);
const { msg: { rid, _id: mid, private: isPrivate } } = messageArgs(data);
const user = Meteor.user();
const room = Rooms.findOne({ _id: rid });
if (roomTypes.readOnly(room._id, user._id)) {
if (!room) {
return false;
}
if (!instance.subscription.get()) {
return false;
}
if (isPrivate) {
return false;
}
if (roomTypes.readOnly(room._id, user._id) && !room.reactWhenReadOnly) {
return false;
}

@ -218,9 +218,11 @@
</span>
</li>
{{/each}}
<li class="add-reaction">
<span class="icon-people-plus"></span>
</li>
{{#unless hideAddReaction}}
<li class="add-reaction">
<span class="icon-people-plus"></span>
</li>
{{/unless}}
</ul>
{{/unless}}
{{/unless}}

@ -323,6 +323,25 @@ Template.message.helpers({
return 'hidden';
}
},
hideAddReaction() {
const { room, u, msg, subscription } = this;
if (!room) {
return true;
}
if (!subscription) {
return true;
}
if (msg.private) {
return true;
}
if (roomTypes.readOnly(room._id, u._id) && !room.reactWhenReadOnly) {
return true;
}
},
hideMessageActions() {
const { msg } = this;

Loading…
Cancel
Save