-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEW] Add reaction to the last message when get the shortcut +: #7569
Conversation
@@ -192,6 +192,7 @@ Template.messagePopup.onCreated(function() { | |||
return; | |||
} | |||
const value = template.input.value; | |||
const preColon = value.substr(0, value.indexOf(':')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Why not just use trigger: '\\+:'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to this b/c when we select one emoji the string of the emoji replace the string on input-message. In this case, we need to keep the +
caracter before the first :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use:
trigger: '\\+:',
prefix: '+'
Did you try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no. I'll try that thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rodrigok work like a charm 👌
I haven't notice that we can insert a prefix and/or suffix in the final string on config, thanks @rodrigok 🚀
…ocket.Chat into danilomiranda-reactionShortcut
@@ -182,6 +182,12 @@ this.ChatMessages = class ChatMessages { | |||
|
|||
const msg = input.value; | |||
const msgObject = { _id: Random.id(), rid, msg}; | |||
const lastMessage = ChatMessage.findOne({rid}, { fields: { ts: 1 }, sort: { ts: -1 }}); | |||
if (msg[0]+msg[1] === '+:') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use msg.slice(0, 2)
instead of msg[0]+msg[1]
and check if the emoji exists first:
const reaction = msg.slice(1).trim();
if (RocketChat.emoji.list[reaction]) {
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you try you can set a reaction with an invalid emoji like +:as: askjhdak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
How can we trigger an sound error when trying to send a wrong command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not trigger a sound, just send the message, maybe the users is trying to send that as a message
@rodrigok 'If you try you can set a reaction with an invalid emoji like +:as: askjhdak'
…at into reactionShortcut
@RocketChat/core
Closes #3756