diff --git a/ui/package.json b/ui/package.json index df15daf..bf46201 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.0.1", + "version": "0.0.2", "dnaVersion": "0.0.1", "scripts": { "start": "vite --clearScreen false --port $UI_PORT", diff --git a/ui/src/StreamPane.svelte b/ui/src/StreamPane.svelte index 873c0cc..9dc2068 100644 --- a/ui/src/StreamPane.svelte +++ b/ui/src/StreamPane.svelte @@ -76,7 +76,7 @@ let count = parseInt(inputCountElement.value) let delay = parseInt(inputDelayElement.value) setTimeout(() => { - _sendMessage() + _sendMessage(inputCountElement.value) count-=1 inputCountElement.value = `${count}` if (count>0) { @@ -84,10 +84,10 @@ } }, delay); } - const _sendMessage = async () => { + const _sendMessage = async (text) => { const payload: Payload = { type: "Msg", - text: inputElement.value, + text, created: Date.now(), } console.log("SENDING TO",hashes) @@ -267,16 +267,16 @@ label="Delay" > (disabled = !e.target.value || !inputElement.value)} on:keydown={(e) => { if (e.keyCode == 13) { - sendMessage(); + _sendMessage(inputElement.value); e.stopPropagation(); } }} - placeholder="Message" + label="Message" > { } async sendMessage(streamId: string, payload: Payload, agents: AgentPubKey[]) { + console.log("Sending", payload, "to", agents.map(agent=>encodeHashToBase64(agent))) await this.callZome('send_message', { streamId, content: JSON.stringify(payload), @@ -122,7 +123,6 @@ export class ZipTestStore { }); async sendMessage(streamId: string, payload: Payload, agents: AgentPubKey[]) { - console.log("Sending Message to", agents.map(agent=>encodeHashToBase64(agent))) this.addMessageToStream(streamId, {payload, from:this.myAgentPubKey, received:Date.now() }) for (const agent of agents) { let messageList:Array = this.expectations.get(agent) @@ -165,10 +165,10 @@ export class ZipTestStore { stream = this.newStream(streamId) } - stream.addMessage(message) + const firstAdd = stream.addMessage(message) if (message.payload.type == "Msg") { - if (isWeContext()) { - this.weaveClient.notifyFrame([ + if (firstAdd && isWeContext()) { + await this.weaveClient.notifyFrame([ { title: `message from ${encodeHashToBase64(message.from)}`, body: message.payload.text, @@ -225,18 +225,18 @@ export class ZipTestStore { } // we just received a message from someone who we are expecting // to have acked something but they haven't so we retry to send the message - if (messageList.length > 0) { - const streams = Object.values(get(this.streams)) - for (const msgId of messageList) { - for (const stream of streams) { - const msg = stream.findMessage(msgId) - if (msg) { - console.log("Resending", msg) - await this.client.sendMessage(stream.id, msg.payload, [message.from]) - } - } - } - } + // if (messageList.length > 0) { + // const streams = Object.values(get(this.streams)) + // for (const msgId of messageList) { + // for (const stream of streams) { + // const msg = stream.findMessage(msgId) + // if (msg) { + // console.log("Resending", msg) + // await this.client.sendMessage(stream.id, msg.payload, [message.from]) + // } + // } + // } + // } } }