fix bug where drag&drop would not create new object versions

This commit is contained in:
marlon-erler
2024-07-13 11:56:15 +02:00
parent ea4d27ce64
commit 414ab87110
4 changed files with 35 additions and 13 deletions
+13 -1
View File
@@ -334,7 +334,7 @@ export class Chat {
return messageObject;
};
createObjectContent = () => {
createObjectContent = (): MessageObjectContent => {
return {
id: React.UUID(),
isoDateVersionCreated: new Date().toISOString(),
@@ -348,6 +348,18 @@ export class Chat {
messageObject.contentVersions[content.id] = content;
};
updateObjectContent = (
messageObject: MessageObject,
content: MessageObjectContent
): void => {
const latest = this.getMostRecentContent(messageObject);
Object.entries(content).forEach((entry) => {
const [key, value] = entry;
latest[key] = value;
});
this.addObjectContent(messageObject, latest);
};
addObject = (
messageObject: MessageObject,
ignoreIfUnchanged: boolean = false
+3 -2
View File
@@ -108,8 +108,9 @@ function KanbanBoardView(
const messageObject = chat.objects.value.get(id);
if (!messageObject) return;
const latest = chat.getMostRecentContent(messageObject);
latest.categoryName = kanbanBoard.category;
const newContent = chat.createObjectContent();
newContent.categoryName = kanbanBoard.category;
chat.updateObjectContent(messageObject, newContent);
chat.addObjectAndSend(messageObject);
}
+4 -3
View File
@@ -230,9 +230,10 @@ function StatusColumnView(
const messageObject = chat.objects.value.get(id);
if (!messageObject) return;
const latest = chat.getMostRecentContent(messageObject);
latest.status = status;
latest.categoryName = category;
const newContent = chat.createObjectContent();
newContent.categoryName = category;
newContent.status = status;
chat.updateObjectContent(messageObject, newContent);
chat.addObjectAndSend(messageObject);
}