aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <1498135+alyssarosenzweig@users.noreply.github.com>2020-02-20 13:41:28 -0500
committerGitHub <noreply@github.com>2020-02-20 19:41:28 +0100
commit78ef31dcf57a1aa16d9b51897501b81116b22ffd (patch)
treef0555ceb47be3144d375f7dd99f29fe5b8ad099f /main/src/ui
parenta81af020f30bfda4dec60a52aec142a0c5abb297 (diff)
downloaddino-78ef31dcf57a1aa16d9b51897501b81116b22ffd.tar.gz
dino-78ef31dcf57a1aa16d9b51897501b81116b22ffd.zip
Show /me commands appropriately in last message view (#699)
Closes #600 Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala29
1 files changed, 25 insertions, 4 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index 705aad29..7b017258 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -140,14 +140,35 @@ public class ConversationSelectorRow : ListBoxRow {
MessageItem message_item = last_content_item as MessageItem;
Message last_message = message_item.message;
- if (conversation.type_ == Conversation.Type.GROUPCHAT) {
- nick_label.label = Util.get_participant_display_name(stream_interactor, conversation, last_message.from, true) + ": ";
+ string body = last_message.body;
+ bool me_command = body.has_prefix("/me ");
+
+ /* If we have a /me command, we always show the display
+ * name, and we don't set me_is_me on
+ * get_participant_display_name, since that will return
+ * "Me" (internationalized), whereas /me commands expect to
+ * be in the third person. We also omit the colon in this
+ * case, and strip off the /me prefix itself. */
+
+ if (conversation.type_ == Conversation.Type.GROUPCHAT || me_command) {
+ nick_label.label = Util.get_participant_display_name(stream_interactor, conversation, last_message.from, !me_command);
+ } else if (last_message.direction == Message.DIRECTION_SENT) {
+ nick_label.label = _("Me");
} else {
- nick_label.label = last_message.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
+ nick_label.label = "";
+ }
+
+ if (me_command) {
+ /* Don't slice off the space after /me */
+ body = body.slice("/me".length, body.length);
+ } else if (nick_label.label.length > 0) {
+ /* TODO: Is this valid for RTL languages? */
+ nick_label.label += ": ";
}
message_label.attributes.filter((attr) => attr.equal(attr_style_new(Pango.Style.ITALIC)));
- message_label.label = Util.summarize_whitespaces_to_space(last_message.body);
+ message_label.label = Util.summarize_whitespaces_to_space(body);
+
break;
case FileItem.TYPE:
FileItem file_item = last_content_item as FileItem;