From 0f7d781fd5163061b9e3680b95ee03ae89fd2ea3 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Sat, 13 Jul 2024 11:24:58 +0200 Subject: [PATCH] ignore incoming objects when unchanged --- dist/index.js | 3 +++ src/Model/chatModel.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/dist/index.js b/dist/index.js index 444e9221..a3d8453f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -958,11 +958,14 @@ addObject = (messageObject, ignoreIfUnchanged = false) => { const existingObject = this.objects.value.get(messageObject.id); if (existingObject) { + let isIdentical = existingObject.title == messageObject.title; existingObject.title = messageObject.title; Object.values(messageObject.contentVersions).forEach((content) => { if (existingObject.contentVersions[content.id]) return; this.addObjectContent(existingObject, content); + isIdentical = false; }); + if (isIdentical && ignoreIfUnchanged) return; this.objects.set(existingObject.id, existingObject); } else { this.objects.set(messageObject.id, messageObject); diff --git a/src/Model/chatModel.ts b/src/Model/chatModel.ts index 5197ddae..9469b169 100644 --- a/src/Model/chatModel.ts +++ b/src/Model/chatModel.ts @@ -354,11 +354,15 @@ export class Chat { ): void => { const existingObject = this.objects.value.get(messageObject.id); if (existingObject) { + let isIdentical = existingObject.title == messageObject.title; + existingObject.title = messageObject.title; Object.values(messageObject.contentVersions).forEach((content) => { if (existingObject.contentVersions[content.id]) return; this.addObjectContent(existingObject, content); + isIdentical = false; }); + if (isIdentical && ignoreIfUnchanged) return; this.objects.set(existingObject.id, existingObject); } else { this.objects.set(messageObject.id, messageObject);