From d24fe6314669078d8cf82c157377c2c0623c66d4 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Fri, 12 Jul 2024 20:49:08 +0200 Subject: [PATCH] prevent re-setting unchanged objects --- dist/index.js | 4 ++++ src/Model/chatModel.ts | 4 ++++ src/Views/Objects/objectGridView.tsx | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index e2970ff4..923d2616 100644 --- a/dist/index.js +++ b/dist/index.js @@ -938,9 +938,13 @@ const existingObject = this.objects.value.get(messageObject.id); if (existingObject) { existingObject.title = messageObject.title; + let didChangeObject = false; Object.values(messageObject.contentVersions).forEach((content) => { + if (existingObject.contentVersions[content.id]) return; this.addObjectContent(existingObject, content); + didChangeObject = true; }); + if (didChangeObject == false) 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 7d0f2afa..1bd709cc 100644 --- a/src/Model/chatModel.ts +++ b/src/Model/chatModel.ts @@ -351,10 +351,14 @@ export class Chat { addObject = (messageObject: MessageObject): void => { const existingObject = this.objects.value.get(messageObject.id); if (existingObject) { + let didChangeObject = existingObject.title != messageObject.title; existingObject.title = messageObject.title; Object.values(messageObject.contentVersions).forEach((content) => { + if (existingObject.contentVersions[content.id]) return; this.addObjectContent(existingObject, content); + didChangeObject = true; }); + if (didChangeObject == false) return; this.objects.set(existingObject.id, existingObject); } else { this.objects.set(messageObject.id, messageObject); diff --git a/src/Views/Objects/objectGridView.tsx b/src/Views/Objects/objectGridView.tsx index 4b8e5783..ec65d1d6 100644 --- a/src/Views/Objects/objectGridView.tsx +++ b/src/Views/Objects/objectGridView.tsx @@ -3,7 +3,6 @@ import * as React from "bloatless-react"; import { Chat, MessageObject } from "../../Model/chatModel"; import { ObjectEntryView } from "./objectEntryView"; -import { PlaceholderView } from "./placeholderView"; export function ObjectGridView( chat: Chat,