store received items

This commit is contained in:
marlon-erler
2024-07-11 00:56:06 +02:00
parent b7dbe6b13d
commit d3604d474b
9 changed files with 23 additions and 14 deletions
BIN
View File
Binary file not shown.
+8 -4
View File
@@ -295,7 +295,7 @@
} }
}); });
} catch { } catch {
throw `error: cannot process subscribe:children directive because ListItemConverter is not defined. Usage: "subscribe:children={[list, converter]}"; you can find a more detailed example in the documentation`; throw `error: cannot process subscribe:children directive because StateItemConverter is not defined. Usage: "subscribe:children={[list, converter]}"; you can find a more detailed example in the documentation`;
} }
} }
} }
@@ -501,7 +501,7 @@
const { sender, body, channel, isoDate, itemData } = JSON.parse( const { sender, body, channel, isoDate, itemData } = JSON.parse(
data.messageBody data.messageBody
); );
if (itemData != void 0) { if (itemData && itemData.id && itemData.title) {
return this.handleItem(itemData); return this.handleItem(itemData);
} }
this.handleMessage({ this.handleMessage({
@@ -522,7 +522,7 @@
if (selectedChat.value != this) this.hasUnreadMessages.value = true; if (selectedChat.value != this) this.hasUnreadMessages.value = true;
}; };
handleItem = (itemData) => { handleItem = (itemData) => {
console.log(itemData); this.items.set(itemData.id, itemData);
}; };
// messages // messages
createMessage = async (messageText, itemData) => { createMessage = async (messageText, itemData) => {
@@ -1110,7 +1110,11 @@
title: "new item" title: "new item"
}); });
} }
return /* @__PURE__ */ createElement("div", { class: "chat-tool-view" }, /* @__PURE__ */ createElement("button", { "on:click": createItem }, "+"), /* @__PURE__ */ createElement("hr", null)); const itemConverter = (item) => {
console.log(item);
return /* @__PURE__ */ createElement("span", null, item.title);
};
return /* @__PURE__ */ createElement("div", { class: "chat-tool-view" }, /* @__PURE__ */ createElement("button", { "on:click": createItem }, "+"), /* @__PURE__ */ createElement("hr", null), /* @__PURE__ */ createElement("div", { "children:append": [chat.items, itemConverter] }));
} }
// src/Views/messageComposer.tsx // src/Views/messageComposer.tsx
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"dependencies": { "dependencies": {
"bloatless-react": "^1.3.2", "bloatless-react": "^1.3.3",
"esbuild": "latest", "esbuild": "latest",
"udn-frontend": "^1.0.7-beta1" "udn-frontend": "^1.0.7-beta1"
}, },
+2 -2
View File
@@ -151,7 +151,7 @@ export class Chat {
data.messageBody data.messageBody
); );
if (itemData != undefined) { if (itemData && itemData.id && itemData.title) {
return this.handleItem(itemData); return this.handleItem(itemData);
} }
@@ -177,7 +177,7 @@ export class Chat {
}; };
handleItem = (itemData: Item): void => { handleItem = (itemData: Item): void => {
console.log(itemData); this.items.set(itemData.id, itemData);
}; };
// messages // messages
+1 -1
View File
@@ -12,7 +12,7 @@ import {
import { Chat } from "../Model/chatModel"; import { Chat } from "../Model/chatModel";
import { translation } from "../translations"; import { translation } from "../translations";
const chatConverter: React.ListItemConverter<Chat> = (chat) => { const chatConverter: React.StateItemConverter<Chat> = (chat) => {
function select() { function select() {
selectChat(chat); selectChat(chat);
} }
+1 -1
View File
@@ -20,7 +20,7 @@ export function ChatOptionModal(chat: Chat, isPresented: React.State<boolean>) {
shouldShowKey.value == true ? "text" : "password" shouldShowKey.value == true ? "text" : "password"
); );
const secondaryChannelConverter: React.ListItemConverter<string> = ( const secondaryChannelConverter: React.StateItemConverter<string> = (
secondaryChannel secondaryChannel
) => { ) => {
function remove() { function remove() {
+7 -2
View File
@@ -1,6 +1,7 @@
import * as React from "bloatless-react"; import * as React from "bloatless-react";
import { Chat } from "../Model/chatModel"; import { Chat, Item } from "../Model/chatModel";
import { translation } from "../translations"; import { translation } from "../translations";
export function ChatToolView(chat: Chat) { export function ChatToolView(chat: Chat) {
@@ -11,11 +12,15 @@ export function ChatToolView(chat: Chat) {
}); });
} }
const itemConverter: React.StateItemConverter<Item> = (item) => {
return <span>{item.title}</span>;
};
return ( return (
<div class="chat-tool-view"> <div class="chat-tool-view">
<button on:click={createItem}>+</button> <button on:click={createItem}>+</button>
<hr></hr> <hr></hr>
<div children:append={[chat.items, itemConverter]}></div>
</div> </div>
); );
} }
+1 -1
View File
@@ -17,7 +17,7 @@ import {
import { translation } from "../translations"; import { translation } from "../translations";
const addressConverter: React.ListItemConverter<string> = (address) => { const addressConverter: React.StateItemConverter<string> = (address) => {
return <option>{address}</option>; return <option>{address}</option>;
}; };
+2 -2
View File
@@ -5,7 +5,7 @@ import { Chat, ChatMessage } from "../Model/chatModel";
import { translation } from "../translations"; import { translation } from "../translations";
export function ThreadView(chat: Chat) { export function ThreadView(chat: Chat) {
const messageConverter: React.ListItemConverter<ChatMessage> = (message) => { const messageConverter: React.StateItemConverter<ChatMessage> = (message) => {
function resendMessage() { function resendMessage() {
chat.resendMessage(message); chat.resendMessage(message);
} }
@@ -72,7 +72,7 @@ export function ThreadView(chat: Chat) {
); );
}; };
const outboxMessageConverter: React.ListItemConverter<ChatMessage> = ( const outboxMessageConverter: React.StateItemConverter<ChatMessage> = (
message message
) => { ) => {
function remove() { function remove() {