Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jsxc/jsxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/LastMessageCorrectionPlugin.ts')
-rw-r--r--src/plugins/LastMessageCorrectionPlugin.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/LastMessageCorrectionPlugin.ts b/src/plugins/LastMessageCorrectionPlugin.ts
index 39786f53..c3db4c46 100644
--- a/src/plugins/LastMessageCorrectionPlugin.ts
+++ b/src/plugins/LastMessageCorrectionPlugin.ts
@@ -54,6 +54,10 @@ export default class LastMessageCorrectionPlugin extends AbstractPlugin {
pluginAPI.addPreSendMessageStanzaProcessor(this.addReplaceElementToStanza, 90);
pluginAPI.addAfterReceiveMessageProcessor(this.checkMessageCorrection, 90);
+
+ pluginAPI.registerChatMessageMenuItem({
+ generate: this.generateCorrectMessageMenuItem,
+ });
}
private commandHandler = async (args: string[], contact: IContact, messageString: string) => {
@@ -148,4 +152,34 @@ export default class LastMessageCorrectionPlugin extends AbstractPlugin {
return [contact, message, stanza];
};
+
+ private generateCorrectMessageMenuItem = (contact: IContact, message: IMessage) => {
+ if (message.isOutgoing()) {
+ const lastOutgoingMessage = contact.getTranscript().getFirstOutgoingMessage().getLastVersion();
+
+ if (lastOutgoingMessage.getUid() === message.getUid()) {
+ const chatWindow = contact.getChatWindow();
+
+ return {
+ id: 'lmc-edit',
+ label: '',
+ icon: 'edit',
+ handler: () => {
+ let plaintextMessage = message.getPlaintextMessage();
+
+ if (message.hasAttachment()) {
+ const attachment = message.getAttachment();
+
+ chatWindow.setAttachment(attachment);
+ plaintextMessage = plaintextMessage.replace(attachment.getData() + '\n', '');
+ }
+
+ chatWindow.setInput(CORRECTION_CMD + ' ' + plaintextMessage);
+ },
+ };
+ }
+ }
+
+ return false;
+ };
}