From 04a966f025812dfb1aa1955fd73ca9edf8ff9670 Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Sat, 20 Sep 2025 18:08:54 +0900 Subject: [PATCH 1/3] always use username for posting --- .../src/components/chat/MessageInput.svelte | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/client/src/components/chat/MessageInput.svelte b/packages/client/src/components/chat/MessageInput.svelte index 46a0041..97e5145 100644 --- a/packages/client/src/components/chat/MessageInput.svelte +++ b/packages/client/src/components/chat/MessageInput.svelte @@ -21,15 +21,18 @@ const identity = useQuery(api.users.me, {}); let messageContent = $state(""); - let authorName = $state(""); let showEmojiPalette = $state(false); let showFileSelector = $state(false); let attachedFiles = $state([]); - $effect(() => { - if (identity?.data && !authorName) { - authorName = identity.data.name ?? identity.data.email ?? "匿名"; - } + const clickable = $derived.by(() => { + // empty content + if (!messageContent.trim() && attachedFiles.length === 0) return false; + // post ongoing + if (sendMessageMutation.processing) return false; + // identity not loaded yet + if (!identity.data) return false; + return true; }); const uploader = new FileUploader(() => ({ @@ -38,6 +41,7 @@ async function sendMessage() { if (!messageContent.trim() && attachedFiles.length === 0) return; + if (!identity.data) return; const attachments = (await uploader.uploadAll(attachedFiles)).map( (it) => it.id, @@ -46,7 +50,7 @@ await sendMessageMutation.run({ channelId, content: messageContent.trim() || "", - author: authorName.trim() || "匿名", + author: identity.data.name, parentId: replyingTo?._id ?? undefined, attachments, }); @@ -116,14 +120,7 @@ /> {/if} -
- -
+
@@ -164,8 +161,7 @@