chore: formatting
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Kieran 2024-01-26 11:18:06 +00:00
parent 7a6637a86f
commit d3e6ddc64c
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
8 changed files with 80 additions and 75 deletions

View File

@ -56,7 +56,6 @@ const Timeline = (props: TimelineProps) => {
[props.postsOnly, props.ignoreModeration, props.followDistance],
);
const mainFeed = useMemo(() => {
return filterPosts(feed.main ?? []);
}, [feed.main, filterPosts]);

View File

@ -56,5 +56,5 @@ export function wotScore(pubkey: string) {
}
export function sortByWoT(pubkeys: Array<string>) {
return pubkeys.sort((a, b) => wotScore(a) > wotScore(b) ? 1 : -1);
}
return pubkeys.sort((a, b) => (wotScore(a) > wotScore(b) ? 1 : -1));
}

View File

@ -48,15 +48,17 @@ export function useRateHistory(symbol: string, size: number, leaveOpen = false)
const feed = useRequestBuilder(sub);
return removeUndefined(feed.map(a => {
const tag = a.tags.find(a => a[0] === "d" && a[1] === symbol);
if (!tag) return undefined;
return {
time: a?.created_at,
ask: Number(tag[2]),
bid: Number(tag[3]),
low: Number(tag[4]),
hight: Number(tag[5]),
};
}));
return removeUndefined(
feed.map(a => {
const tag = a.tags.find(a => a[0] === "d" && a[1] === symbol);
if (!tag) return undefined;
return {
time: a?.created_at,
ask: Number(tag[2]),
bid: Number(tag[3]),
low: Number(tag[4]),
hight: Number(tag[5]),
};
}),
);
}

View File

@ -115,8 +115,7 @@ export function NotificationGroup({
</div>
<div className="flex flex-col w-max g12">
<div className="flex w-max overflow-hidden">
{sortByWoT(pubkeys
.filter(a => a !== "anon"))
{sortByWoT(pubkeys.filter(a => a !== "anon"))
.slice(0, 12)
.map(v => (
<ProfileImage

View File

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

View File

@ -58,7 +58,7 @@ const SearchPage = () => {
return {
type: "post_keyword",
discriminator: keyword,
items: [keyword]
items: [keyword],
} as TimelineSubject;
}, [keyword]);

View File

@ -262,4 +262,4 @@ export default function WalletPage(props: { showHistory: boolean }) {
{walletInfo()}
</div>
);
}
}

View File

@ -4,31 +4,36 @@ import { Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "rec
import { useRateHistory } from "@/Hooks/useRates";
export default function PriceChart({ interval, range }: { interval: number, range: number }) {
export default function PriceChart({ interval, range }: { interval: number; range: number }) {
const history = useRateHistory("BTCUSD", range, true);
const reduced = useMemo(() => {
let min = Number.MAX_SAFE_INTEGER, max = 0;
let minAsk = Number.MAX_SAFE_INTEGER, maxAsk = 0;
const ret = history.reduce((acc, v) => {
const key = v.time - (v.time % interval);
acc[key] ??= { time: key, ask: 0, bid: 0 };
acc[key].ask = v.ask;
acc[key].bid = v.bid;
if (key < min) {
min = key
}
if (key > max) {
max = key;
}
if (v.ask > maxAsk) {
maxAsk = v.ask;
}
if (v.ask < minAsk) {
minAsk = v.ask;
}
return acc;
}, {} as Record<string, { time: number, ask: number | null, bid: number | null }>);
let min = Number.MAX_SAFE_INTEGER,
max = 0;
let minAsk = Number.MAX_SAFE_INTEGER,
maxAsk = 0;
const ret = history.reduce(
(acc, v) => {
const key = v.time - (v.time % interval);
acc[key] ??= { time: key, ask: 0, bid: 0 };
acc[key].ask = v.ask;
acc[key].bid = v.bid;
if (key < min) {
min = key;
}
if (key > max) {
max = key;
}
if (v.ask > maxAsk) {
maxAsk = v.ask;
}
if (v.ask < minAsk) {
minAsk = v.ask;
}
return acc;
},
{} as Record<string, { time: number; ask: number | null; bid: number | null }>,
);
for (let x = min; x < max; x += interval) {
ret[x] ??= { time: x, ask: null, bid: null };
@ -37,38 +42,37 @@ export default function PriceChart({ interval, range }: { interval: number, rang
}, [history, interval]);
const lastRate = useMemo(() => {
return history.reduce((acc, v) => {
if (acc.time < v.time) {
acc = v;
}
return acc;
}, { time: 0, ask: 0, bid: 0 } as { time: number, ask: number, bid: number })
return history.reduce(
(acc, v) => {
if (acc.time < v.time) {
acc = v;
}
return acc;
},
{ time: 0, ask: 0, bid: 0 } as { time: number; ask: number; bid: number },
);
}, [history]);
return <>
<h3 className="text-right">
<FormattedNumber value={lastRate.ask} style="currency" currency="USD" />
</h3>
<ResponsiveContainer height={250}>
<LineChart data={Object.values(reduced.data)}>
<XAxis
dataKey="time"
type="number"
scale="time"
domain={["dataMin", "dataMax"]}
hide={true}
/>
<YAxis
dataKey="ask"
type="number"
scale="auto"
domain={["dataMin - 100", "dataMax + 100"]}
tickFormatter={v => Number(v).toLocaleString()}
hide={true}
/>
<Tooltip content={() => ""} />
<Line dataKey="ask" type="monotone" dot={false} connectNulls={false} stroke="var(--primary-bg)" />
</LineChart>
</ResponsiveContainer>
</>;
return (
<>
<h3 className="text-right">
<FormattedNumber value={lastRate.ask} style="currency" currency="USD" />
</h3>
<ResponsiveContainer height={250}>
<LineChart data={Object.values(reduced.data)}>
<XAxis dataKey="time" type="number" scale="time" domain={["dataMin", "dataMax"]} hide={true} />
<YAxis
dataKey="ask"
type="number"
scale="auto"
domain={["dataMin - 100", "dataMax + 100"]}
tickFormatter={v => Number(v).toLocaleString()}
hide={true}
/>
<Tooltip content={() => ""} />
<Line dataKey="ask" type="monotone" dot={false} connectNulls={false} stroke="var(--primary-bg)" />
</LineChart>
</ResponsiveContainer>
</>
);
}