chore: formatting

This commit is contained in:
2024-01-17 15:48:30 +00:00
parent aa58ec4185
commit adb9fe5c2e
11 changed files with 56 additions and 54 deletions

View File

@ -14,7 +14,13 @@ import { formatShort } from "@/Utils/Number";
import { notificationContext } from "./notificationContext";
import { NotificationContext } from "./Notifications";
export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEvent>; onClick?: (link: NostrLink) => void; }) {
export function NotificationGroup({
evs,
onClick,
}: {
evs: Array<TaggedNostrEvent>;
onClick?: (link: NostrLink) => void;
}) {
const { ref, inView } = useInView({ triggerOnce: true });
const { formatMessage } = useIntl();
const kind = evs[0].kind;
@ -30,7 +36,7 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
return zap.anonZap ? "anon" : zap.sender ?? a.pubkey;
}
return a.pubkey;
})
}),
);
const firstPubkey = pubkeys[0];
const firstPubkeyProfile = useUserProfile(inView ? (firstPubkey === "anon" ? "" : firstPubkey) : "");
@ -64,7 +70,8 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
values={{
n,
name,
}} />
}}
/>
);
}
case EventKind.Repost: {
@ -75,7 +82,8 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
values={{
n,
name,
}} />
}}
/>
);
}
case EventKind.ZapReceipt: {
@ -86,7 +94,8 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
values={{
n,
name,
}} />
}}
/>
);
}
}
@ -114,7 +123,8 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
showUsername={kind === EventKind.TextNote}
pubkey={v}
size={40}
overrideUsername={v === "" ? formatMessage({ defaultMessage: "Anon", id: "bfvyfs" }) : undefined} />
overrideUsername={v === "" ? formatMessage({ defaultMessage: "Anon", id: "bfvyfs" }) : undefined}
/>
))}
</div>
{kind !== EventKind.TextNote && (
@ -123,7 +133,7 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
pubkeys.length - 1,
firstPubkey === "anon"
? formatMessage({ defaultMessage: "Anon", id: "bfvyfs" })
: getDisplayName(firstPubkeyProfile, firstPubkey)
: getDisplayName(firstPubkeyProfile, firstPubkey),
)}
</div>
)}
@ -136,7 +146,8 @@ export function NotificationGroup({ evs, onClick }: { evs: Array<TaggedNostrEven
} else {
navigate(`/${context.encode(CONFIG.eventLinkPrefix)}`);
}
}} />
}}
/>
)}
</div>
</>

View File

@ -44,8 +44,9 @@ export default function NotificationsPage({ onClick }: { onClick?: (link: NostrL
const timeGrouped = useMemo(() => {
return myNotifications.reduce((acc, v) => {
const key = `${timeKey(v)}:${notificationContext(v as TaggedNostrEvent)?.encode(CONFIG.eventLinkPrefix)}:${v.kind
}`;
const key = `${timeKey(v)}:${notificationContext(v as TaggedNostrEvent)?.encode(CONFIG.eventLinkPrefix)}:${
v.kind
}`;
if (acc.has(key)) {
unwrap(acc.get(key)).push(v as TaggedNostrEvent);
} else {
@ -64,8 +65,7 @@ export default function NotificationsPage({ onClick }: { onClick?: (link: NostrL
</Suspense>
)}
{login.publicKey &&
[...timeGrouped.entries()]
.map(([k, g]) => <NotificationGroup key={k} evs={g} onClick={onClick} />)}
[...timeGrouped.entries()].map(([k, g]) => <NotificationGroup key={k} evs={g} onClick={onClick} />)}
<ShowMoreInView onClick={() => {}} />
</div>

View File

@ -2,13 +2,7 @@ import { FeedCache } from "@snort/shared";
import { ReactNode, useEffect, useState, useSyncExternalStore } from "react";
import { FormattedMessage, FormattedNumber } from "react-intl";
import {
Chats,
GiftsCache,
PaymentsCache,
RelayMetrics,
UserCache,
} from "@/Cache";
import { Chats, GiftsCache, PaymentsCache, RelayMetrics, UserCache } from "@/Cache";
import AsyncButton from "@/Components/Button/AsyncButton";
import { Relay } from "@/system";
@ -70,23 +64,22 @@ function RelayCacheStats() {
<div className="flex flex-col g4">
<FormattedMessage defaultMessage="Worker Relay" id="xSoIUU" />
{Object.entries(counts).map(([k, v]) => {
return <small key={k}>
<FormattedMessage
defaultMessage="{n} kind {k} events"
id="I97cCX"
values={{
n: <FormattedNumber value={v} />,
k: k
}}
/>
</small>
return (
<small key={k}>
<FormattedMessage
defaultMessage="{n} kind {k} events"
id="I97cCX"
values={{
n: <FormattedNumber value={v} />,
k: k,
}}
/>
</small>
);
})}
</div>
<div>
<AsyncButton onClick={() => {
}}>
<AsyncButton onClick={() => {}}>
<FormattedMessage defaultMessage="Clear" id="/GCoTA" />
</AsyncButton>
</div>