From 7ca9a18aa8a1dbdb6f8dfb0e0fc1904e384dacf0 Mon Sep 17 00:00:00 2001 From: Marcos Defendi Date: Wed, 15 May 2019 10:05:01 -0300 Subject: [PATCH 1/2] Remove jump to message duplicated link --- app/message-star/client/actionButton.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/message-star/client/actionButton.js b/app/message-star/client/actionButton.js index 505667943303..499600c9bbbd 100644 --- a/app/message-star/client/actionButton.js +++ b/app/message-star/client/actionButton.js @@ -64,7 +64,7 @@ Meteor.startup(function() { id: 'jump-to-star-message', icon: 'jump', label: 'Jump_to_message', - context: ['starred', 'threads'], + context: ['starred'], action() { const { msg: message } = messageArgs(this); if (window.matchMedia('(max-width: 500px)').matches) { @@ -73,10 +73,11 @@ Meteor.startup(function() { RoomHistoryManager.getSurroundingMessages(message, 50); }, condition(message) { - if (Subscriptions.findOne({ rid: message.rid }) == null) { + if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { return false; } - return true; + + return message.starred && message.starred.find((star) => star._id === Meteor.userId()); }, order: 100, group: 'menu', @@ -87,17 +88,18 @@ Meteor.startup(function() { icon: 'permalink', label: 'Get_link', classes: 'clipboard', - context: ['starred', 'threads'], + context: ['starred'], async action(event) { const { msg: message } = messageArgs(this); $(event.currentTarget).attr('data-clipboard-text', await MessageAction.getPermaLink(message._id)); toastr.success(TAPi18n.__('Copied')); }, condition(message) { - if (Subscriptions.findOne({ rid: message.rid }) == null) { + if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { return false; } - return true; + + return message.starred && message.starred.find((star) => star._id === Meteor.userId()); }, order: 101, group: 'menu', From 9c6c689c37069a1901caaecb88d302b527449bbb Mon Sep 17 00:00:00 2001 From: Marcos Defendi Date: Wed, 15 May 2019 10:41:08 -0300 Subject: [PATCH 2/2] Remove star message if the setting in disabled --- app/message-star/client/actionButton.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/message-star/client/actionButton.js b/app/message-star/client/actionButton.js index 499600c9bbbd..d856d6b3f570 100644 --- a/app/message-star/client/actionButton.js +++ b/app/message-star/client/actionButton.js @@ -25,7 +25,7 @@ Meteor.startup(function() { }); }, condition(message) { - if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { + if (Subscriptions.findOne({ rid: message.rid }) == null || !settings.get('Message_AllowStarring')) { return false; } @@ -50,7 +50,7 @@ Meteor.startup(function() { }); }, condition(message) { - if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { + if (Subscriptions.findOne({ rid: message.rid }) == null || !settings.get('Message_AllowStarring')) { return false; } @@ -73,7 +73,7 @@ Meteor.startup(function() { RoomHistoryManager.getSurroundingMessages(message, 50); }, condition(message) { - if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { + if (Subscriptions.findOne({ rid: message.rid }) == null || !settings.get('Message_AllowStarring')) { return false; } @@ -95,7 +95,7 @@ Meteor.startup(function() { toastr.success(TAPi18n.__('Copied')); }, condition(message) { - if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) { + if (Subscriptions.findOne({ rid: message.rid }) == null || !settings.get('Message_AllowStarring')) { return false; }