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

Commit 9f3b80e

Browse files
committed
fix ben's problems
1 parent 5c7e85b commit 9f3b80e

21 files changed

+294
-479
lines changed

src/assets/plus.png

-19 Bytes
Loading

src/components/Activity.tsx

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createEffect, createSignal, For, Match, Show, Switch } from "solid-js";
55
import shuffle from "~/assets/icons/shuffle.svg";
66
import {
77
ActivityDetailsModal,
8-
ActivityItem,
98
Card,
109
HackActivityType,
1110
NiceP
@@ -44,11 +43,16 @@ export function UnifiedActivityItem(props: {
4443
return props.item.contacts[0];
4544
};
4645

46+
// TODO: figure out what other shit we should filter out
4747
const message = () => {
48-
if (props.item.labels.length === 0) {
48+
const filtered = props.item.labels.filter(
49+
(l) => l !== "SWAP" && !l.startsWith("LN Channel:")
50+
);
51+
if (filtered.length === 0) {
4952
return undefined;
5053
}
51-
return props.item.labels[0];
54+
55+
return filtered[0];
5256
};
5357

5458
const shouldShowShuffle = () => {
@@ -69,6 +73,13 @@ export function UnifiedActivityItem(props: {
6973
if (props.item.labels.length > 0 && props.item.labels[0] === "SWAP") {
7074
return "swapped to";
7175
}
76+
if (
77+
props.item.labels.length > 0 &&
78+
props.item.labels[0] === "Swept Force Close"
79+
) {
80+
return undefined;
81+
}
82+
7283
return "sent";
7384
};
7485

@@ -104,29 +115,34 @@ export function UnifiedActivityItem(props: {
104115

105116
return (
106117
<>
107-
<GenericItem
108-
primaryAvatarUrl={
109-
shouldShowShuffle()
110-
? shuffle
111-
: primaryContact()?.image_url || ""
112-
}
113-
primaryName={
114-
props.item.inbound
115-
? primaryContact()?.name || "Unknown"
116-
: "You"
117-
}
118-
genericAvatar={shouldShowGeneric()}
119-
verb={verb()}
120-
message={message()}
121-
secondaryName={secondaryName()}
122-
amount={
123-
props.item.amount_sats
124-
? BigInt(props.item.amount_sats || 0)
125-
: undefined
126-
}
127-
date={timeAgo(props.item.last_updated)}
128-
accent={props.item.inbound ? "green" : undefined}
129-
/>
118+
<button class="pt-3 first-of-type:pt-0" onClick={() => click()}>
119+
<GenericItem
120+
primaryAvatarUrl={
121+
shouldShowShuffle()
122+
? shuffle
123+
: primaryContact()?.image_url || ""
124+
}
125+
primaryName={
126+
props.item.inbound
127+
? primaryContact()?.name || "Unknown"
128+
: "You"
129+
}
130+
genericAvatar={shouldShowGeneric()}
131+
verb={verb()}
132+
message={message()}
133+
secondaryName={secondaryName()}
134+
amount={
135+
props.item.amount_sats
136+
? BigInt(props.item.amount_sats || 0)
137+
: undefined
138+
}
139+
date={timeAgo(props.item.last_updated)}
140+
accent={props.item.inbound ? "green" : undefined}
141+
visibility={
142+
props.item.kind === "Lightning" ? "private" : undefined
143+
}
144+
/>
145+
</button>
130146
{/* <pre>{JSON.stringify(props.item, null, 2)}</pre> */}
131147
</>
132148
// <ActivityItem
@@ -143,7 +159,7 @@ export function UnifiedActivityItem(props: {
143159
);
144160
}
145161

146-
export function CombinedActivity(props: { limit?: number }) {
162+
export function CombinedActivity() {
147163
const [state, _actions] = useMegaStore();
148164
const i18n = useI18n();
149165

@@ -219,18 +235,6 @@ export function CombinedActivity(props: { limit?: number }) {
219235
<NiceP>Don't forget to back up your seed words!</NiceP>
220236
</Card>
221237
</Match>
222-
<Match when={props.limit && activity().length > props.limit}>
223-
<div class="flex w-full flex-col divide-y divide-m-grey-800 overflow-x-clip">
224-
<For each={activity().slice(0, props.limit)}>
225-
{(activityItem) => (
226-
<UnifiedActivityItem
227-
item={activityItem}
228-
onClick={openDetailsModal}
229-
/>
230-
)}
231-
</For>
232-
</div>
233-
</Match>
234238
<Match when={activity().length >= 0}>
235239
<div class="flex w-full flex-col divide-y divide-m-grey-800 overflow-x-clip">
236240
<For each={activity()}>
@@ -244,15 +248,6 @@ export function CombinedActivity(props: { limit?: number }) {
244248
</div>
245249
</Match>
246250
</Switch>
247-
{/* Only show on the home screen */}
248-
<Show when={props.limit}>
249-
<A
250-
href="/activity"
251-
class="self-center font-semibold text-m-red no-underline active:text-m-red/80"
252-
>
253-
{i18n.t("activity.view_all")}
254-
</A>
255-
</Show>
256251
</>
257252
);
258253
}

src/components/ActivityDetailsModal.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,13 @@ function LightningDetails(props: { info: MutinyInvoice; tags?: TagItem }) {
217217
</TinyButton>
218218
</KeyValue>
219219
</Show>
220-
<KeyValue key={i18n.t("activity.transaction_details.status")}>
221-
{props.info.paid
222-
? i18n.t("activity.transaction_details.paid")
223-
: i18n.t("activity.transaction_details.unpaid")}
224-
</KeyValue>
220+
<Show when={!props.info.paid}>
221+
<KeyValue
222+
key={i18n.t("activity.transaction_details.status")}
223+
>
224+
i18n.t("activity.transaction_details.unpaid")
225+
</KeyValue>
226+
</Show>
225227
<KeyValue key={i18n.t("activity.transaction_details.date")}>
226228
<FormatPrettyPrint ts={Number(props.info.last_updated)} />
227229
</KeyValue>
@@ -235,12 +237,7 @@ function LightningDetails(props: { info: MutinyInvoice; tags?: TagItem }) {
235237
<KeyValue key={i18n.t("activity.transaction_details.invoice")}>
236238
<MiniStringShower text={props.info.bolt11 ?? ""} />
237239
</KeyValue>
238-
<KeyValue
239-
key={i18n.t("activity.transaction_details.payment_hash")}
240-
>
241-
<MiniStringShower text={props.info.payment_hash ?? ""} />
242-
</KeyValue>
243-
<Show when={props.info.paid}>
240+
<Show when={props.info.paid && !props.info.inbound}>
244241
<KeyValue
245242
key={i18n.t(
246243
"activity.transaction_details.payment_preimage"
@@ -371,11 +368,6 @@ function OnchainDetails(props: {
371368
"Pending"
372369
)}
373370
</KeyValue>
374-
<Show when={props.kind === "ChannelOpen" && channelInfo()}>
375-
<KeyValue key={i18n.t("activity.transaction_details.peer")}>
376-
<MiniStringShower text={channelInfo()?.peer ?? ""} />
377-
</KeyValue>
378-
</Show>
379371
<KeyValue key={i18n.t("activity.transaction_details.txid")}>
380372
<div class="flex gap-1">
381373
{/* Have to do all these shenanigans because css / html is hard */}

src/components/ContactButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ export function ContactButton(props: {
88
onClick: () => void;
99
}) {
1010
return (
11-
<div class="flex items-center gap-2">
11+
<button class="flex items-center gap-2" onClick={() => props.onClick()}>
1212
<LabelCircle
1313
name={props.contact.name}
1414
image_url={props.contact.primal_image_url}
1515
contact
1616
label={false}
17-
onClick={() => props.onClick()}
1817
/>
1918
<div class="flex flex-1 flex-col items-start">
2019
<h2 class="overflow-hidden overflow-ellipsis text-base font-semibold">
@@ -24,6 +23,6 @@ export function ContactButton(props: {
2423
{props.contact.ln_address || ""}
2524
</h3>
2625
</div>
27-
</div>
26+
</button>
2827
);
2928
}

src/components/ContactViewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
MiniStringShower,
1212
showToast,
1313
SimpleDialog,
14-
SmallHeader,
1514
VStack
1615
} from "~/components";
1716
import { useI18n } from "~/i18n/context";

src/components/Fab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export function FabMenu(props: {
3333
return (
3434
<nav
3535
ref={(el) => (navRef = el)}
36-
class="fixed bottom-[calc(2rem+5rem)] rounded-xl bg-neutral-700/30 px-2 backdrop-blur-lg"
36+
class="fixed rounded-xl bg-neutral-700/30 px-2 backdrop-blur-lg"
3737
classList={{
38-
"right-8": props.right,
39-
"left-8": props.left
38+
"right-8 bottom-[calc(2rem+5rem)]": props.right,
39+
"left-4 bottom-[calc(2rem+2rem)]": props.left
4040
}}
4141
>
4242
{props.children}

src/components/GenericItem.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import redClose from "~/assets/icons/red-close.svg";
66
import { Clock } from "~/assets/svg/Clock";
77
import { Globe } from "~/assets/svg/Globe";
88
import { PrivateEye } from "~/assets/svg/Private";
9-
import { LabelCircle, LoadingSpinner, SharpButton } from "~/components";
9+
import { LabelCircle, LoadingSpinner } from "~/components";
1010

1111
export function GenericItem(props: {
1212
primaryAvatarUrl: string;
1313
secondaryAvatarUrl?: string;
1414
primaryName: string;
1515
secondaryName?: string;
16-
verb: string;
16+
verb?: string;
1717
amount?: bigint;
1818
date?: string;
1919
due?: string;
2020
message?: string;
2121
accent?: "green";
22-
public?: boolean;
22+
visibility?: "public" | "private";
2323
showFiat?: boolean;
2424
genericAvatar?: boolean;
2525
forceSecondary?: boolean;
@@ -48,21 +48,23 @@ export function GenericItem(props: {
4848
onClick={props.primaryOnClick}
4949
/>
5050
</div>
51-
<div class="flex flex-col items-start gap-1 px-2">
51+
<div class="flex flex-col items-start justify-center gap-1 self-center px-2">
5252
{/* TITLE TEXT */}
53-
<h2 class="text-sm">
54-
<strong
55-
classList={{
56-
"text-m-grey-400": props.genericAvatar
57-
}}
58-
>
59-
{props.primaryName}
60-
</strong>
61-
<span class="font-light">{` ${props.verb} `}</span>
62-
<Show when={props.secondaryName}>
63-
<strong>{props.secondaryName}</strong>
64-
</Show>
65-
</h2>
53+
<Show when={props.primaryName && props.verb}>
54+
<h2 class="text-sm">
55+
<strong
56+
classList={{
57+
"text-m-grey-400": props.genericAvatar
58+
}}
59+
>
60+
{props.primaryName}
61+
</strong>
62+
<span class="font-light">{` ${props.verb} `}</span>
63+
<Show when={props.secondaryName}>
64+
<strong>{props.secondaryName}</strong>
65+
</Show>
66+
</h2>
67+
</Show>
6668
<div class="flex flex-wrap gap-1">
6769
{/* AMOUNT */}
6870
<Show when={props.amount}>
@@ -102,11 +104,11 @@ export function GenericItem(props: {
102104
{/* DATE WITH SECOND AVATAR */}
103105
<Show when={props.date}>
104106
<div class="flex items-center gap-1 text-m-grey-400">
105-
<Show when={props.public}>
107+
<Show when={props.visibility === "public"}>
106108
{/* <img src={globe} width={12} height={12} /> */}
107109
<Globe />
108110
</Show>
109-
<Show when={!props.public}>
111+
<Show when={props.visibility === "private"}>
110112
<PrivateEye />
111113
{/* <img src={privateEye} width={12} height={12} /> */}
112114
</Show>
@@ -151,19 +153,19 @@ export function GenericItem(props: {
151153
>
152154
<div class="flex gap-4">
153155
<button
154-
class="rounded border-b border-t border-b-white/10 border-t-white/50 bg-m-grey-750 active:-mb-[1px] active:mt-[1px]"
156+
class="flex h-10 w-10 items-center justify-center rounded border-b border-t border-b-white/10 border-t-white/50 bg-m-grey-750 p-1 active:-mb-[1px] active:mt-[1px]"
155157
onClick={() =>
156158
props.approveAction && props.approveAction()
157159
}
158160
>
159161
<img
160-
class="h-[1.5rem] w-[1.5rem]"
162+
class="h-[2rem] w-[2rem]"
161163
src={greenCheck}
162164
alt="Approve"
163165
/>
164166
</button>
165167
<button
166-
class="rounded border-b border-t border-b-white/10 border-t-white/50 bg-m-grey-750 active:-mb-[1px] active:mt-[1px]"
168+
class="flex h-10 w-10 items-center justify-center rounded border-b border-t border-b-white/10 border-t-white/50 bg-m-grey-750 p-1 active:-mb-[1px] active:mt-[1px]"
167169
onClick={() =>
168170
props.rejectAction && props.rejectAction()
169171
}

src/components/HomeSubnav.tsx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { createSignal, Show, Suspense } from "solid-js";
1+
import {
2+
createEffect,
3+
createResource,
4+
createSignal,
5+
Show,
6+
Suspense
7+
} from "solid-js";
28

39
import {
410
CombinedActivity,
@@ -18,6 +24,23 @@ export function HomeSubnav() {
1824
"me" | "everybody" | "requests"
1925
>("me");
2026

27+
const [pending, { refetch }] = createResource(async () => {
28+
try {
29+
const pending =
30+
await state.mutiny_wallet?.get_pending_nwc_invoices();
31+
return pending?.length || 0;
32+
} catch (e) {
33+
console.error(e);
34+
return 0;
35+
}
36+
});
37+
38+
createEffect(() => {
39+
if (state.is_syncing) {
40+
refetch();
41+
}
42+
});
43+
2144
return (
2245
<>
2346
<div class="flex gap-2">
@@ -44,15 +67,27 @@ export function HomeSubnav() {
4467
</button>
4568

4669
<button
47-
class="rounded px-2 py-1 text-sm"
70+
class="flex items-center gap-1 rounded px-2 py-1 text-sm"
4871
classList={{
4972
"bg-m-red": activeView() === "requests",
5073
"bg-m-grey-800 text-m-grey-400":
5174
activeView() !== "requests"
5275
}}
5376
onClick={() => setActiveView("requests")}
5477
>
55-
Requests
78+
<span>Requests </span>
79+
<Suspense fallback={<></>}>
80+
<Show when={pending.latest && pending.latest > 0}>
81+
<span
82+
class="inline-flex h-5 w-5 items-center justify-center rounded-full bg-white/20 text-xs"
83+
classList={{
84+
"text-white": !!((pending.latest || 0) > 0)
85+
}}
86+
>
87+
{pending()}
88+
</span>
89+
</Show>
90+
</Suspense>
5691
</button>
5792
</div>
5893

0 commit comments

Comments
 (0)