From 57f7747ccc1293a699fe455fd6232e2c671d7dde Mon Sep 17 00:00:00 2001 From: rachel-mp4 Date: Sat, 11 Oct 2025 16:17:57 -0400 Subject: [PATCH] just gonna try this and see what breaks --- package-lock.json | 6 +- src/lib/components/AutoGrowTextArea.svelte | 1 + src/lib/components/Transmitter.svelte | 53 +++++-- src/lib/wscontext.svelte.ts | 174 ++++++++++++++++++++- 4 files changed, 217 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 504c7ad..4478ac3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -558,9 +558,9 @@ "license": "(Apache-2.0 AND BSD-3-Clause)" }, "node_modules/@rachel-mp4/lrcproto": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@rachel-mp4/lrcproto/-/lrcproto-1.0.4.tgz", - "integrity": "sha512-C5wtSj1oa8YhKb7U0v4YgNx4OMfrtJmhCDlZ0BMmCrBA93IX153pbjro8WtXDNfZXyyUgOLkjzd1VrsMgUA3KA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@rachel-mp4/lrcproto/-/lrcproto-1.2.0.tgz", + "integrity": "sha512-DSbEf5wxS0ArjgYkh6ZVLqpB3qvGlGB8Co9AzDeK9fnYZIfwmVgSQemT/Um2e2Oaq/mioNAx8gph6T01wQz1dQ==", "license": "MIT", "dependencies": { "typescript": "^3.9.10" diff --git a/src/lib/components/AutoGrowTextArea.svelte b/src/lib/components/AutoGrowTextArea.svelte index fa9fc90..0e85a87 100644 --- a/src/lib/components/AutoGrowTextArea.svelte +++ b/src/lib/components/AutoGrowTextArea.svelte @@ -230,6 +230,7 @@ position: absolute; top: 0; left: 0; + max-height: 16rem; } .selected.emoji-result { background: var(--fg); diff --git a/src/lib/components/Transmitter.svelte b/src/lib/components/Transmitter.svelte index 8d10f7a..f760ca2 100644 --- a/src/lib/components/Transmitter.svelte +++ b/src/lib/components/Transmitter.svelte @@ -14,6 +14,8 @@ let nick = $state(defaultNick ?? "wanderer"); let innerWidth = $state(0); let isDesktop = $derived(innerWidth > 1000); + let imageURL: string | undefined = $state(); + let imageAlt: string = $state(""); $effect(() => { if (ctx) { ctx.setNick(nick); @@ -75,19 +77,25 @@ }; const convertFileToImageItem = (blob: File) => { const blobUrl = URL.createObjectURL(blob); - const img = document.createElement("img"); - img.src = blobUrl; - const image: Image = { - type: "image", - image: img, - id: 0, - active: false, - mine: false, - muted: false, - startedAt: Date.now(), - }; - ctx.pushItem(image); - console.log("pushed image item!"); + ctx.initImage(blob); + imageURL = blobUrl; + }; + const cancelimagepost = () => { + if (imageURL) { + URL.revokeObjectURL(imageURL); + } + ctx.atpblob = undefined; + ctx.pubImage(""); + imageAlt = ""; + imageURL = undefined; + }; + const uploadimage = () => { + ctx.pubImage(imageAlt); + if (imageURL) { + URL.revokeObjectURL(imageURL); + } + imageAlt = ""; + imageURL = undefined; }; @@ -136,6 +144,25 @@ maxlength={65535} fs={isDesktop ? "2rem" : "1rem"} /> + {#if imageURL !== undefined} +
+ {imageAlt} + + + {#if ctx.atpblob} + confirm + {:else} + uploading... + {/if} + +
+ {/if}