2024-07-11 18:54:56 +02:00
|
|
|
import * as React from "bloatless-react";
|
|
|
|
|
|
|
|
|
|
import { Chat, MessageObject } from "../../Model/chatModel";
|
|
|
|
|
|
2024-07-11 22:27:15 +02:00
|
|
|
import { ObjectEntryView } from "./objectEntryView";
|
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>
|
|
|
|
|
) {
|
|
|
|
|
const objectConverter: React.StateItemConverter<MessageObject> = (
|
|
|
|
|
messageObject
|
|
|
|
|
) => {
|
2024-07-11 22:27:15 +02:00
|
|
|
return ObjectEntryView(
|
|
|
|
|
chat,
|
|
|
|
|
messageObject,
|
|
|
|
|
selectedObject,
|
|
|
|
|
isShowingObjectModal
|
2024-07-11 18:54:56 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
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 19:29:12 +02:00
|
|
|
notes.value.size == 0 ? (
|
2024-07-11 18:54:56 +02:00
|
|
|
<div class="flex-column width-100 height-100 align-center justify-center secondary">
|
|
|
|
|
{translation.noNotes}
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div
|
|
|
|
|
class="grid gap padding"
|
2024-07-11 19:29:12 +02:00
|
|
|
style="grid-template-columns: repeat(auto-fill, minmax(350px, 1fr))"
|
|
|
|
|
children:prepend={[notes, objectConverter]}
|
2024-07-11 18:54:56 +02:00
|
|
|
></div>
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return <div class="width-100 height-100" children:set={content}></div>;
|
|
|
|
|
}
|