diff --git a/src/plugins/sib-reply-to-message.js b/src/plugins/sib-reply-to-message.js index 982528ec66aff0ce1c81134a64460f474fa8c6ec..ad53b1c5c15749772345f46f3c59528ae862cb45 100644 --- a/src/plugins/sib-reply-to-message.js +++ b/src/plugins/sib-reply-to-message.js @@ -13,6 +13,12 @@ converse.plugins.add('sib-reply-to-message', { } api.listen.on('getMessageActionButtons', (el, buttons) => { + + // Do not add the reply button if the message is retracted or correcting + if (el.is_retracted || el.correcting) { + return buttons; + } + buttons.push({ 'i18n_text': __('Reply'), 'handler': ev => { diff --git a/src/plugins/sib-retract-file-upload.js b/src/plugins/sib-retract-file-upload.js new file mode 100644 index 0000000000000000000000000000000000000000..f7aa683c699f5984ba5149aac348d2787d1a809d --- /dev/null +++ b/src/plugins/sib-retract-file-upload.js @@ -0,0 +1,34 @@ +/** + * Allow the user to retract a file upload. + */ +converse.plugins.add('sib-retract-file-upload', { + initialize() { + const _converse = this._converse; + const { api, Message } = _converse; + + api.settings.extend({ + 'allow_upload_retraction': 'own', + }); + + const MessageMixin = { + /** + * The message can be retracted if the above option is correctly set. + * Overrides the 'allow_message_retraction' setting if disabled. + * + * @private + * @method _converse.Messages#mayBeRetracted + * @returns { Boolean } + */ + mayBeRetracted() { + return _mayBeRetracted.call(this) || ( + this.get('sender') === 'me' + && this.get('oob_url') + && ['all', 'own'].includes(api.settings.get('allow_upload_retraction')) + ); + }, + }; + + const _mayBeRetracted = Message.prototype.mayBeRetracted; + Object.assign(Message.prototype, MessageMixin); + }, +}); diff --git a/src/solid-xmpp-chat.js b/src/solid-xmpp-chat.js index cfb903488ace9d1df0f418f2b9881816e647daab..af138fb3282e0e430d31cafdf3300b0801fabf6c 100644 --- a/src/solid-xmpp-chat.js +++ b/src/solid-xmpp-chat.js @@ -15,6 +15,7 @@ import './plugins/sib-history-improved.js'; import './plugins/sib-mention-mobile.js'; import './plugins/sib-remove-notifications.js'; import './plugins/sib-reply-to-message.js'; +import './plugins/sib-retract-file-upload.js'; import './plugins/sib-scroll-down-on-focus.js'; import './plugins/sib-subscribe-to-rai.js'; @@ -240,6 +241,7 @@ export const SolidXMPPChat = { 'sib-mention-mobile', 'sib-remove-notifications', 'sib-reply-to-message', + 'sib-retract-file-upload', 'sib-scroll-down-on-focus', 'sib-subscribe-to-rai', ],