Commit 77a0a01e authored by Ariel Fuggini's avatar Ariel Fuggini Committed by GitHub

Makes message with errors non-editable (#2089)

* Makes message with errors non-editable
parent 346e5d89
......@@ -1681,6 +1681,16 @@ describe("A Chat Message", function () {
await u.waitUntil(() => view.model.messages.length > 3);
await new Promise(resolve => view.model.messages.once('rendered', resolve));
expect(view.content.querySelectorAll('.chat-error').length).toEqual(1);
// Ensure messages with error are not editable
document.querySelectorAll('.chat-msg__actions').forEach(elem => {
expect(elem.querySelector('.chat-msg__action-edit')).toBe(null)
})
view.model.messages.forEach(message => {
const isEditable = message.get('editable');
isEditable && expect(isEditable).toBe(false);
})
done();
}));
......
......@@ -48,6 +48,7 @@ describe("A Groupchat Message", function () {
expect(message.get('received')).toBeUndefined();
expect(message.get('body')).toBe('hello world');
expect(message.get('error_text')).toBe(err_msg_text);
expect(message.get('editable')).toBe(false);
done();
}));
});
......
......@@ -702,7 +702,7 @@ describe("Message Retractions", function () {
expect(view.model.messages.length).toBe(1);
expect(view.model.messages.at(0).get('retracted')).toBeFalsy();
expect(view.model.messages.at(0).get('is_ephemeral')).toBeFalsy();
expect(view.model.messages.at(0).get('editable')).toBeTruthy();
expect(view.model.messages.at(0).get('editable')).toBe(false);
const errmsg = view.el.querySelector('.chat-msg__error');
expect(errmsg.textContent.trim()).toBe("You're not allowed to retract your message.");
......
......@@ -407,6 +407,7 @@ converse.plugins.add('converse-chat', {
'error_condition': attrs.error_condition,
'error_text': attrs.error_text,
'error_type': attrs.error_type,
'editable': false,
};
if (attrs.msgid === message.get('retraction_id')) {
// The error message refers to a retraction
......@@ -979,10 +980,7 @@ converse.plugins.add('converse-chat', {
* @param { String } send_time - time when the message was sent
*/
setEditable (attrs, send_time) {
if (attrs.is_headline) {
return;
}
if (u.isEmptyMessage(attrs) || attrs.sender !== 'me') {
if (attrs.is_headline || u.isEmptyMessage(attrs) || attrs.sender !== 'me') {
return;
}
if (api.settings.get('allow_message_corrections') === 'all') {
......
......@@ -631,6 +631,7 @@ converse.plugins.add('converse-muc', {
'error_condition': attrs.error_condition,
'error_text': attrs.error_text,
'error_type': attrs.error_type,
'editable': false,
};
if (attrs.msgid === message.get('retraction_id')) {
// The error message refers to a retraction
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment