Files
CT/src/Views/Objects/noteObjectsView.tsx
T

36 lines
941 B
TypeScript
Raw Normal View History

2024-07-11 18:54:56 +02:00
import * as React from "bloatless-react";
import { Chat, MessageObject } from "../../Model/chatModel";
2024-07-11 22:35:46 +02:00
import { ObjectGridView } from "./objectGridView";
2024-07-11 18:54:56 +02:00
import { translation } from "../../translations";
export function NoteObjectsView(
chat: Chat,
selectedObject: React.State<MessageObject | undefined>,
isShowingObjectModal: React.State<boolean>
) {
2024-07-11 19:29:12 +02:00
const notes = new React.ListState<MessageObject>();
chat.objects.subscribe(() => {
notes.clear();
chat.objects.value.forEach((messageObject) => {
const latest = chat.getMostRecentContent(messageObject);
if (!latest.noteContent) return;
notes.add(messageObject);
});
});
2024-07-11 18:54:56 +02:00
const content = React.createProxyState([chat.objects], () =>
2024-07-11 22:35:46 +02:00
ObjectGridView(
chat,
notes,
selectedObject,
isShowingObjectModal,
translation.noNotes
2024-07-11 18:54:56 +02:00
)
);
return <div class="width-100 height-100" children:set={content}></div>;
}