chore: formatting
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
7a6637a86f
commit
d3e6ddc64c
|
@ -56,7 +56,6 @@ const Timeline = (props: TimelineProps) => {
|
||||||
[props.postsOnly, props.ignoreModeration, props.followDistance],
|
[props.postsOnly, props.ignoreModeration, props.followDistance],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const mainFeed = useMemo(() => {
|
const mainFeed = useMemo(() => {
|
||||||
return filterPosts(feed.main ?? []);
|
return filterPosts(feed.main ?? []);
|
||||||
}, [feed.main, filterPosts]);
|
}, [feed.main, filterPosts]);
|
||||||
|
|
|
@ -56,5 +56,5 @@ export function wotScore(pubkey: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sortByWoT(pubkeys: Array<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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,15 +48,17 @@ export function useRateHistory(symbol: string, size: number, leaveOpen = false)
|
||||||
|
|
||||||
const feed = useRequestBuilder(sub);
|
const feed = useRequestBuilder(sub);
|
||||||
|
|
||||||
return removeUndefined(feed.map(a => {
|
return removeUndefined(
|
||||||
const tag = a.tags.find(a => a[0] === "d" && a[1] === symbol);
|
feed.map(a => {
|
||||||
if (!tag) return undefined;
|
const tag = a.tags.find(a => a[0] === "d" && a[1] === symbol);
|
||||||
return {
|
if (!tag) return undefined;
|
||||||
time: a?.created_at,
|
return {
|
||||||
ask: Number(tag[2]),
|
time: a?.created_at,
|
||||||
bid: Number(tag[3]),
|
ask: Number(tag[2]),
|
||||||
low: Number(tag[4]),
|
bid: Number(tag[3]),
|
||||||
hight: Number(tag[5]),
|
low: Number(tag[4]),
|
||||||
};
|
hight: Number(tag[5]),
|
||||||
}));
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,7 @@ export function NotificationGroup({
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col w-max g12">
|
<div className="flex flex-col w-max g12">
|
||||||
<div className="flex w-max overflow-hidden">
|
<div className="flex w-max overflow-hidden">
|
||||||
{sortByWoT(pubkeys
|
{sortByWoT(pubkeys.filter(a => a !== "anon"))
|
||||||
.filter(a => a !== "anon"))
|
|
||||||
.slice(0, 12)
|
.slice(0, 12)
|
||||||
.map(v => (
|
.map(v => (
|
||||||
<ProfileImage
|
<ProfileImage
|
||||||
|
|
|
@ -40,8 +40,9 @@ export default function NotificationsPage({ onClick }: { onClick?: (link: NostrL
|
||||||
|
|
||||||
const timeGrouped = useMemo(() => {
|
const timeGrouped = useMemo(() => {
|
||||||
return myNotifications.reduce((acc, v) => {
|
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)) {
|
if (acc.has(key)) {
|
||||||
unwrap(acc.get(key)).push(v as TaggedNostrEvent);
|
unwrap(acc.get(key)).push(v as TaggedNostrEvent);
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +63,7 @@ export default function NotificationsPage({ onClick }: { onClick?: (link: NostrL
|
||||||
{login.publicKey &&
|
{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={() => { }} />
|
<ShowMoreInView onClick={() => {}} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -58,7 +58,7 @@ const SearchPage = () => {
|
||||||
return {
|
return {
|
||||||
type: "post_keyword",
|
type: "post_keyword",
|
||||||
discriminator: keyword,
|
discriminator: keyword,
|
||||||
items: [keyword]
|
items: [keyword],
|
||||||
} as TimelineSubject;
|
} as TimelineSubject;
|
||||||
}, [keyword]);
|
}, [keyword]);
|
||||||
|
|
||||||
|
|
|
@ -262,4 +262,4 @@ export default function WalletPage(props: { showHistory: boolean }) {
|
||||||
{walletInfo()}
|
{walletInfo()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,31 +4,36 @@ import { Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "rec
|
||||||
|
|
||||||
import { useRateHistory } from "@/Hooks/useRates";
|
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 history = useRateHistory("BTCUSD", range, true);
|
||||||
|
|
||||||
const reduced = useMemo(() => {
|
const reduced = useMemo(() => {
|
||||||
let min = Number.MAX_SAFE_INTEGER, max = 0;
|
let min = Number.MAX_SAFE_INTEGER,
|
||||||
let minAsk = Number.MAX_SAFE_INTEGER, maxAsk = 0;
|
max = 0;
|
||||||
const ret = history.reduce((acc, v) => {
|
let minAsk = Number.MAX_SAFE_INTEGER,
|
||||||
const key = v.time - (v.time % interval);
|
maxAsk = 0;
|
||||||
acc[key] ??= { time: key, ask: 0, bid: 0 };
|
const ret = history.reduce(
|
||||||
acc[key].ask = v.ask;
|
(acc, v) => {
|
||||||
acc[key].bid = v.bid;
|
const key = v.time - (v.time % interval);
|
||||||
if (key < min) {
|
acc[key] ??= { time: key, ask: 0, bid: 0 };
|
||||||
min = key
|
acc[key].ask = v.ask;
|
||||||
}
|
acc[key].bid = v.bid;
|
||||||
if (key > max) {
|
if (key < min) {
|
||||||
max = key;
|
min = key;
|
||||||
}
|
}
|
||||||
if (v.ask > maxAsk) {
|
if (key > max) {
|
||||||
maxAsk = v.ask;
|
max = key;
|
||||||
}
|
}
|
||||||
if (v.ask < minAsk) {
|
if (v.ask > maxAsk) {
|
||||||
minAsk = v.ask;
|
maxAsk = v.ask;
|
||||||
}
|
}
|
||||||
return acc;
|
if (v.ask < minAsk) {
|
||||||
}, {} as Record<string, { time: number, ask: number | null, bid: number | null }>);
|
minAsk = v.ask;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, { time: number; ask: number | null; bid: number | null }>,
|
||||||
|
);
|
||||||
|
|
||||||
for (let x = min; x < max; x += interval) {
|
for (let x = min; x < max; x += interval) {
|
||||||
ret[x] ??= { time: x, ask: null, bid: null };
|
ret[x] ??= { time: x, ask: null, bid: null };
|
||||||
|
@ -37,38 +42,37 @@ export default function PriceChart({ interval, range }: { interval: number, rang
|
||||||
}, [history, interval]);
|
}, [history, interval]);
|
||||||
|
|
||||||
const lastRate = useMemo(() => {
|
const lastRate = useMemo(() => {
|
||||||
return history.reduce((acc, v) => {
|
return history.reduce(
|
||||||
if (acc.time < v.time) {
|
(acc, v) => {
|
||||||
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 acc;
|
||||||
|
},
|
||||||
|
{ time: 0, ask: 0, bid: 0 } as { time: number; ask: number; bid: number },
|
||||||
|
);
|
||||||
}, [history]);
|
}, [history]);
|
||||||
|
|
||||||
return <>
|
return (
|
||||||
<h3 className="text-right">
|
<>
|
||||||
<FormattedNumber value={lastRate.ask} style="currency" currency="USD" />
|
<h3 className="text-right">
|
||||||
</h3>
|
<FormattedNumber value={lastRate.ask} style="currency" currency="USD" />
|
||||||
<ResponsiveContainer height={250}>
|
</h3>
|
||||||
<LineChart data={Object.values(reduced.data)}>
|
<ResponsiveContainer height={250}>
|
||||||
<XAxis
|
<LineChart data={Object.values(reduced.data)}>
|
||||||
dataKey="time"
|
<XAxis dataKey="time" type="number" scale="time" domain={["dataMin", "dataMax"]} hide={true} />
|
||||||
type="number"
|
<YAxis
|
||||||
scale="time"
|
dataKey="ask"
|
||||||
domain={["dataMin", "dataMax"]}
|
type="number"
|
||||||
hide={true}
|
scale="auto"
|
||||||
/>
|
domain={["dataMin - 100", "dataMax + 100"]}
|
||||||
<YAxis
|
tickFormatter={v => Number(v).toLocaleString()}
|
||||||
dataKey="ask"
|
hide={true}
|
||||||
type="number"
|
/>
|
||||||
scale="auto"
|
<Tooltip content={() => ""} />
|
||||||
domain={["dataMin - 100", "dataMax + 100"]}
|
<Line dataKey="ask" type="monotone" dot={false} connectNulls={false} stroke="var(--primary-bg)" />
|
||||||
tickFormatter={v => Number(v).toLocaleString()}
|
</LineChart>
|
||||||
hide={true}
|
</ResponsiveContainer>
|
||||||
/>
|
</>
|
||||||
<Tooltip content={() => ""} />
|
);
|
||||||
<Line dataKey="ask" type="monotone" dot={false} connectNulls={false} stroke="var(--primary-bg)" />
|
|
||||||
</LineChart>
|
|
||||||
</ResponsiveContainer>
|
|
||||||
</>;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue