When writing a message make sure the author's typing state is set to none

Thu, 17 Oct 2024 23:57:22 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 17 Oct 2024 23:57:22 -0500
changeset 43017
09661a988eab
parent 43016
158d07e5cd54
child 43018
78cd7c6e8c40

When writing a message make sure the author's typing state is set to none

This allows protocols to be lazy and not need to send a typing state of none
across the wire as well as not having to worry about it at all.

Testing Done:
Sending a message from senpai and verified the typing state changed when the message was written to the conversation.

Reviewed at https://reviews.imfreedom.org/r/3594/

libpurple/purpleconversation.c file | annotate | diff | comparison | revisions
--- a/libpurple/purpleconversation.c	Thu Oct 17 23:51:30 2024 -0500
+++ b/libpurple/purpleconversation.c	Thu Oct 17 23:57:22 2024 -0500
@@ -1483,6 +1483,8 @@
 purple_conversation_write_message(PurpleConversation *conversation,
                                   PurpleMessage *message)
 {
+	PurpleContactInfo *info = NULL;
+
 	g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
 	g_return_if_fail(message != NULL);
 
@@ -1506,6 +1508,20 @@
 		}
 	}
 
+	info = purple_message_get_author(message);
+	if(PURPLE_IS_CONTACT_INFO(info)) {
+		PurpleConversationMember *member = NULL;
+		PurpleConversationMembers *members = NULL;
+
+		members = purple_conversation_get_members(conversation);
+		member = purple_conversation_members_find_member(members, info);
+		if(PURPLE_IS_CONVERSATION_MEMBER(member)) {
+			purple_conversation_member_set_typing_state(member,
+			                                            PURPLE_TYPING_STATE_NONE,
+			                                            0);
+		}
+	}
+
 	g_list_store_append(conversation->messages, message);
 }
 

mercurial