fix object editing

This commit is contained in:
marlon-erler
2024-07-11 16:45:45 +02:00
parent a824ad97d5
commit 4cc9201bc5
4 changed files with 145 additions and 101 deletions
+11 -8
View File
@@ -9,11 +9,18 @@ import { translation } from "../../translations";
export function ChatToolView(chat: Chat) {
const isShowingObjectModal = new React.State(false);
const selectedObject = new React.State<MessageObject | undefined>(undefined);
const objectModal = React.createProxyState([selectedObject], () => {
if (selectedObject.value == undefined) return <div></div>;
const objectModal = React.createProxyState(
[chat.objects, selectedObject],
() => {
if (selectedObject.value == undefined) return <div></div>;
return ObjectDetailModal(chat, selectedObject.value, isShowingObjectModal);
});
return ObjectDetailModal(
chat,
selectedObject.value,
isShowingObjectModal
);
}
);
function createItem() {
const newObject = chat.createObjectFromTitle("New item");
@@ -23,10 +30,6 @@ export function ChatToolView(chat: Chat) {
const itemConverter: React.StateItemConverter<MessageObject> = (
messageObject
) => {
const latestObject = chat.getLatestObjectContent(messageObject);
if (!latestObject) return <div></div>; //TODO
function select() {
selectedObject.value = messageObject;
isShowingObjectModal.value = true;