add note objects
This commit is contained in:
@@ -35,7 +35,7 @@ export function AllObjectsView(
|
||||
) : (
|
||||
<div
|
||||
class="grid gap padding"
|
||||
style="grid-template-columns: repeat(auto-fit, minmax(350px, 1fr))"
|
||||
style="grid-template-columns: repeat(auto-fill, minmax(350px, 1fr))"
|
||||
children:prepend={[chat.objects, objectConverter]}
|
||||
></div>
|
||||
)
|
||||
|
||||
@@ -12,6 +12,8 @@ export function NoteObjectsView(
|
||||
const objectConverter: React.StateItemConverter<MessageObject> = (
|
||||
messageObject
|
||||
) => {
|
||||
const latest = chat.getMostRecentContent(messageObject);
|
||||
|
||||
function select() {
|
||||
selectedObject.value = messageObject;
|
||||
isShowingObjectModal.value = true;
|
||||
@@ -21,22 +23,35 @@ export function NoteObjectsView(
|
||||
<button class="tile" on:click={select}>
|
||||
<div>
|
||||
<b>{messageObject.title}</b>
|
||||
<span class="secondary">{messageObject.id}</span>
|
||||
<span class="secondary ellipsis">
|
||||
{latest.noteContent!.split("\n")[0]}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
const content = React.createProxyState([chat.objects], () =>
|
||||
chat.objects.value.size == 0 ? (
|
||||
notes.value.size == 0 ? (
|
||||
<div class="flex-column width-100 height-100 align-center justify-center secondary">
|
||||
{translation.noNotes}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
class="grid gap padding"
|
||||
style="grid-template-columns: repeat(auto-fit, minmax(350px, 1fr))"
|
||||
children:prepend={[chat.objects, objectConverter]}
|
||||
style="grid-template-columns: repeat(auto-fill, minmax(350px, 1fr))"
|
||||
children:prepend={[notes, objectConverter]}
|
||||
></div>
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user