Skip to content

Commit

Permalink
handle embedded in messages
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Apr 12, 2024
1 parent 9140efa commit 21dfa1f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/routes/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ function SingleMessage(props: {
if (result.value?.cashu_token) {
return {
type: "cashu",
message_without_invoice: props.dm.message.replace(
result.value.original,
""
),
from: props.dm.from,
value: result.value.cashu_token,
amount: result.value.amount_sats
Expand Down Expand Up @@ -168,9 +172,9 @@ function SingleMessage(props: {
);
}

function handleRedeem() {
function handleRedeem(token: string) {
actions.handleIncomingString(
props.dm.message,
token,
(error) => {
showToast(error);
},
Expand Down Expand Up @@ -223,6 +227,11 @@ function SingleMessage(props: {
</Match>
<Match when={parsed()?.type === "cashu"}>
<div class="flex flex-col gap-2">
<Show when={parsed()?.message_without_invoice}>
<p class="!mb-0 break-words">
{parsed()?.message_without_invoice}
</p>
</Show>
<div class="flex items-center gap-2">
<Zap class="h-4 w-4" />
<span>Cashu Token</span>
Expand All @@ -237,7 +246,9 @@ function SingleMessage(props: {
<Button
intent="blue"
layout="xs"
onClick={handleRedeem}
onClick={() =>
handleRedeem(parsed()?.value || "")
}
>
Redeem
</Button>
Expand Down

0 comments on commit 21dfa1f

Please sign in to comment.