prevent re-setting unchanged objects

This commit is contained in:
marlon-erler
2024-07-12 20:49:08 +02:00
parent 2a30dfc1a3
commit d24fe63146
3 changed files with 8 additions and 1 deletions
+4
View File
@@ -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);
+4
View File
@@ -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);
-1
View File
@@ -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,