diff options
author | fiaxh <git@lightrise.org> | 2020-09-06 15:42:54 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-09-07 15:29:32 +0200 |
commit | b60e7da28aad7532b71e92c766ed3cc2698c47c5 (patch) | |
tree | e944bf1e82a5d650c6cbd2695e9bb0d46609c488 /main/src/ui/util | |
parent | 2d31d9d4706d6fea870f9081a1451448f032473d (diff) | |
download | dino-b60e7da28aad7532b71e92c766ed3cc2698c47c5.tar.gz dino-b60e7da28aad7532b71e92c766ed3cc2698c47c5.zip |
Fix message duplication in MUC PMs
Diffstat (limited to 'main/src/ui/util')
-rw-r--r-- | main/src/ui/util/helper.vala | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 8d9fee53..ca2c37d9 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -124,7 +124,7 @@ public static string get_conversation_display_name(StreamInteractor stream_inter return get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart); } if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) { - return _("%s from %s").printf(get_occupant_display_name(stream_interactor, conversation.account, conversation.counterpart), get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart.bare_jid)); + return _("%s from %s").printf(get_occupant_display_name(stream_interactor, conversation, conversation.counterpart), get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart.bare_jid)); } return conversation.counterpart.to_string(); } @@ -141,7 +141,7 @@ public static string get_participant_display_name(StreamInteractor stream_intera return get_real_display_name(stream_interactor, conversation.account, participant, me_is_me) ?? participant.bare_jid.to_string(); } if ((conversation.type_ == Conversation.Type.GROUPCHAT || conversation.type_ == Conversation.Type.GROUPCHAT_PM) && conversation.counterpart.equals_bare(participant)) { - return get_occupant_display_name(stream_interactor, conversation.account, participant); + return get_occupant_display_name(stream_interactor, conversation, participant); } return participant.bare_jid.to_string(); } @@ -182,17 +182,26 @@ private static string get_groupchat_display_name(StreamInteractor stream_interac return jid.to_string(); } -private static string get_occupant_display_name(StreamInteractor stream_interactor, Account account, Jid jid, bool me_is_me = false, bool muc_real_name = false) { +private static string get_occupant_display_name(StreamInteractor stream_interactor, Conversation conversation, Jid jid, bool me_is_me = false, bool muc_real_name = false) { if (muc_real_name) { MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY); - if (muc_manager.is_private_room(account, jid.bare_jid)) { - Jid? real_jid = muc_manager.get_real_jid(jid, account); + if (muc_manager.is_private_room(conversation.account, jid.bare_jid)) { + Jid? real_jid = muc_manager.get_real_jid(jid, conversation.account); if (real_jid != null) { - string? display_name = get_real_display_name(stream_interactor, account, real_jid, me_is_me); + string? display_name = get_real_display_name(stream_interactor, conversation.account, real_jid, me_is_me); if (display_name != null) return display_name; } } } + + // If it's us (jid=our real full JID), display our nick + if (conversation.type_ == Conversation.Type.GROUPCHAT_PM && conversation.account.bare_jid.equals_bare(jid)) { + var muc_conv = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(conversation.counterpart.bare_jid, conversation.account, Conversation.Type.GROUPCHAT); + if (muc_conv != null && muc_conv.nickname != null) { + return muc_conv.nickname; + } + } + return jid.resourcepart ?? jid.to_string(); } |