Bugfix. Show message author in spoiler messages

This commit is contained in:
JC Brand 2018-03-17 14:39:30 +00:00
parent f0ae8c44ff
commit cb0b99ac37
4 changed files with 28 additions and 20 deletions

View File

@ -26,6 +26,10 @@ boxes can no longer be resized horizontally (or diagonally). Perhaps a solution
for this can again be found, but time constraints meant that this feature had
to be removed.
### Bugfixes
- Spoiler messages didn't include the message author's name.
## 3.3.4 (2018-03-05)

View File

@ -44,6 +44,8 @@
_converse.chatboxes.onMessage(msg);
var view = _converse.chatboxviews.get(sender_jid);
expect(_.includes(view.el.querySelector('.chat-msg-author').textContent, 'Max Frankfurter')).toBeTruthy();
var message_content = view.el.querySelector('.chat-msg-content');
expect(message_content.textContent).toBe(spoiler);
@ -78,6 +80,8 @@
_converse.chatboxes.onMessage(msg);
var view = _converse.chatboxviews.get(sender_jid);
expect(_.includes(view.el.querySelector('.chat-msg-author').textContent, 'Max Frankfurter')).toBeTruthy();
var message_content = view.el.querySelector('.chat-msg-content');
expect(message_content.textContent).toBe(spoiler);
@ -124,17 +128,17 @@
expect(view.onMessageSubmitted).toHaveBeenCalled();
/* Test the XML stanza
*
* <message from="dummy@localhost/resource"
* to="max.frankfurter@localhost"
* type="chat"
* id="4547c38b-d98b-45a5-8f44-b4004dbc335e"
* xmlns="jabber:client">
* <body>This is the spoiler</body>
* <active xmlns="http://jabber.org/protocol/chatstates"/>
* <spoiler xmlns="urn:xmpp:spoiler:0"/>
* </message>"
*/
*
* <message from="dummy@localhost/resource"
* to="max.frankfurter@localhost"
* type="chat"
* id="4547c38b-d98b-45a5-8f44-b4004dbc335e"
* xmlns="jabber:client">
* <body>This is the spoiler</body>
* <active xmlns="http://jabber.org/protocol/chatstates"/>
* <spoiler xmlns="urn:xmpp:spoiler:0"/>
* </message>"
*/
var stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
var spoiler_el = stanza.querySelector('spoiler[xmlns="urn:xmpp:spoiler:0"]');
expect(_.isNull(spoiler_el)).toBeFalsy();
@ -144,6 +148,8 @@
expect(body_el.textContent).toBe('This is the spoiler');
/* Test the HTML spoiler message */
expect(view.el.querySelector('.chat-msg-author').textContent.split(':')[1].trim().split(' ')[1]).toBe('me');
var spoiler_msg_el = view.el.querySelector('.chat-msg-content.spoiler');
expect(spoiler_msg_el.textContent).toBe('This is the spoiler');
expect(_.includes(spoiler_msg_el.classList, 'collapsed')).toBeTruthy();
@ -213,6 +219,7 @@
*/
var stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
var spoiler_el = stanza.querySelector('spoiler[xmlns="urn:xmpp:spoiler:0"]');
expect(_.isNull(spoiler_el)).toBeFalsy();
expect(spoiler_el.textContent).toBe('This is the hint');
@ -220,6 +227,8 @@
expect(body_el.textContent).toBe('This is the spoiler');
/* Test the HTML spoiler message */
expect(view.el.querySelector('.chat-msg-author').textContent.split(':')[1].trim().split(' ')[1]).toBe('me');
var spoiler_msg_el = view.el.querySelector('.chat-msg-content.spoiler');
expect(spoiler_msg_el.textContent).toBe('This is the spoiler');
expect(_.includes(spoiler_msg_el.classList, 'collapsed')).toBeTruthy();

View File

@ -611,11 +611,9 @@
} else {
username = attrs.fullname;
}
} else if (attrs.is_spoiler) {
template = tpl_spoiler_message;
} else {
template = tpl_message;
} else {
username = attrs.sender === 'me' && __('me') || fullname;
template = attrs.is_spoiler ? tpl_spoiler_message : tpl_message;
}
const msg_time = moment(attrs.time) || moment;

View File

@ -1,6 +1,3 @@
<li class="toggle-compose-spoiler">
<a class="
{[ if (o.composing_spoiler) { ]} icon-eye-blocked {[ } ]}
{[ if (!o.composing_spoiler) { ]} icon-eye {[ } ]}"
title="{{ o.label_toggle_spoiler }}"></a>
<li class="toggle-compose-spoiler fa {[ if (o.composing_spoiler) { ]} fa-eye-slash {[ } ]} {[ if (!o.composing_spoiler) { ]} fa-eye {[ } ]}"
title="{{ o.label_toggle_spoiler }}"></a>
</li>