mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
fix: canned responses not working when signature is present (#8176)
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -532,17 +532,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
message(updatedMessage) {
|
message(updatedMessage) {
|
||||||
this.hasSlashCommand =
|
// Check if the message starts with a slash.
|
||||||
updatedMessage[0] === '/' && !this.showRichContentEditor;
|
const bodyWithoutSignature = removeSignature(
|
||||||
const hasNextWord = updatedMessage.includes(' ');
|
updatedMessage,
|
||||||
const isShortCodeActive = this.hasSlashCommand && !hasNextWord;
|
this.signatureToApply
|
||||||
if (isShortCodeActive) {
|
);
|
||||||
this.mentionSearchKey = updatedMessage.substring(1);
|
const startsWithSlash = bodyWithoutSignature.startsWith('/');
|
||||||
this.showMentions = true;
|
|
||||||
} else {
|
// Determine if the user is potentially typing a slash command.
|
||||||
this.mentionSearchKey = '';
|
// This is true if the message starts with a slash and the rich content editor is not active.
|
||||||
this.showMentions = false;
|
this.hasSlashCommand = startsWithSlash && !this.showRichContentEditor;
|
||||||
}
|
this.showMentions = this.hasSlashCommand;
|
||||||
|
|
||||||
|
// If a slash command is active, extract the command text after the slash.
|
||||||
|
// If not, reset the mentionSearchKey.
|
||||||
|
this.mentionSearchKey = this.hasSlashCommand
|
||||||
|
? bodyWithoutSignature.substring(1)
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// Autosave the current message draft.
|
||||||
this.doAutoSaveDraft();
|
this.doAutoSaveDraft();
|
||||||
},
|
},
|
||||||
replyType(updatedReplyType, oldReplyType) {
|
replyType(updatedReplyType, oldReplyType) {
|
||||||
@@ -820,10 +828,18 @@ export default {
|
|||||||
this.hideWhatsappTemplatesModal();
|
this.hideWhatsappTemplatesModal();
|
||||||
},
|
},
|
||||||
replaceText(message) {
|
replaceText(message) {
|
||||||
|
if (this.sendWithSignature && !this.private) {
|
||||||
|
// if signature is enabled, append it to the message
|
||||||
|
// appendSignature ensures that the signature is not duplicated
|
||||||
|
// so we don't need to check if the signature is already present
|
||||||
|
message = appendSignature(message, this.signatureToApply);
|
||||||
|
}
|
||||||
|
|
||||||
const updatedMessage = replaceVariablesInMessage({
|
const updatedMessage = replaceVariablesInMessage({
|
||||||
message,
|
message,
|
||||||
variables: this.messageVariables,
|
variables: this.messageVariables,
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$track(CONVERSATION_EVENTS.INSERTED_A_CANNED_RESPONSE);
|
this.$track(CONVERSATION_EVENTS.INSERTED_A_CANNED_RESPONSE);
|
||||||
this.message = updatedMessage;
|
this.message = updatedMessage;
|
||||||
|
|||||||
Reference in New Issue
Block a user