Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit 21dfa1f

Browse files
committed
handle embedded in messages
1 parent 9140efa commit 21dfa1f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/routes/Chat.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ function SingleMessage(props: {
131131
if (result.value?.cashu_token) {
132132
return {
133133
type: "cashu",
134+
message_without_invoice: props.dm.message.replace(
135+
result.value.original,
136+
""
137+
),
134138
from: props.dm.from,
135139
value: result.value.cashu_token,
136140
amount: result.value.amount_sats
@@ -168,9 +172,9 @@ function SingleMessage(props: {
168172
);
169173
}
170174

171-
function handleRedeem() {
175+
function handleRedeem(token: string) {
172176
actions.handleIncomingString(
173-
props.dm.message,
177+
token,
174178
(error) => {
175179
showToast(error);
176180
},
@@ -223,6 +227,11 @@ function SingleMessage(props: {
223227
</Match>
224228
<Match when={parsed()?.type === "cashu"}>
225229
<div class="flex flex-col gap-2">
230+
<Show when={parsed()?.message_without_invoice}>
231+
<p class="!mb-0 break-words">
232+
{parsed()?.message_without_invoice}
233+
</p>
234+
</Show>
226235
<div class="flex items-center gap-2">
227236
<Zap class="h-4 w-4" />
228237
<span>Cashu Token</span>
@@ -237,7 +246,9 @@ function SingleMessage(props: {
237246
<Button
238247
intent="blue"
239248
layout="xs"
240-
onClick={handleRedeem}
249+
onClick={() =>
250+
handleRedeem(parsed()?.value || "")
251+
}
241252
>
242253
Redeem
243254
</Button>

0 commit comments

Comments
 (0)