From 5f8cb35f8a4fba52775c9cbe5caeeb022634dc8c Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 26 Jun 2023 10:12:49 +1000 Subject: [PATCH] feat: make sure changes are needed before calling commit() --- ts/interactions/conversationInteractions.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index 447ee7fbc..24082dcb4 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -727,7 +727,11 @@ export async function updateConversationInteractionState({ status: ConversationInteractionStatus; }) { const convo = getConversationController().get(conversationId); - if (convo) { + if ( + convo && + (type !== convo.get('lastMessageInteractionType') || + status !== convo.get('lastMessageInteractionStatus')) + ) { convo.set('lastMessageInteractionType', type); convo.set('lastMessageInteractionStatus', status); @@ -748,7 +752,10 @@ export async function clearConversationInteractionState({ conversationId: string; }) { const convo = getConversationController().get(conversationId); - if (convo) { + if ( + convo && + (convo.get('lastMessageInteractionType') || convo.get('lastMessageInteractionStatus')) + ) { convo.set('lastMessageInteractionType', undefined); convo.set('lastMessageInteractionStatus', undefined);