chore: fix some eslint warnings
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
2a2c713486
commit
13f4ec3f30
@ -354,18 +354,18 @@ export function NoteCreator() {
|
||||
onChange={e => {
|
||||
note.update(
|
||||
v =>
|
||||
(v.selectedCustomRelays =
|
||||
// set false if all relays selected
|
||||
e.target.checked &&
|
||||
(v.selectedCustomRelays =
|
||||
// set false if all relays selected
|
||||
e.target.checked &&
|
||||
note.selectedCustomRelays &&
|
||||
note.selectedCustomRelays.length == a.length - 1
|
||||
? undefined
|
||||
: // otherwise return selectedCustomRelays with target relay added / removed
|
||||
a.filter(el =>
|
||||
el === r
|
||||
? e.target.checked
|
||||
: !note.selectedCustomRelays || note.selectedCustomRelays.includes(el),
|
||||
)),
|
||||
? undefined
|
||||
: // otherwise return selectedCustomRelays with target relay added / removed
|
||||
a.filter(el =>
|
||||
el === r
|
||||
? e.target.checked
|
||||
: !note.selectedCustomRelays || note.selectedCustomRelays.includes(el),
|
||||
)),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
@ -434,9 +434,9 @@ export function NoteCreator() {
|
||||
onChange={e =>
|
||||
note.update(
|
||||
v =>
|
||||
(v.zapSplits = arr.map((vv, ii) =>
|
||||
ii === i ? { ...vv, weight: Number(e.target.value) } : vv,
|
||||
)),
|
||||
(v.zapSplits = arr.map((vv, ii) =>
|
||||
ii === i ? { ...vv, weight: Number(e.target.value) } : vv,
|
||||
)),
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
@ -117,7 +117,7 @@ export function rootTabItems(base: string, pubKey: string | undefined, tags: New
|
||||
return menuItems;
|
||||
}
|
||||
|
||||
export function RootTabs({ base = "/" }) {
|
||||
export function RootTabs({ base = "/" }: { base: string }) {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const {
|
||||
|
@ -33,7 +33,7 @@ const Tabs = ({ tabs, tab, setTab }: TabsProps) => {
|
||||
return (
|
||||
<div className="tabs" ref={horizontalScroll}>
|
||||
{tabs.map(t => (
|
||||
<TabElement tab={tab} setTab={setTab} t={t} />
|
||||
<TabElement key={tab.value} tab={tab} setTab={setTab} t={t} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
@ -42,7 +42,7 @@ export default function TrendingHashtags({
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <HashTagHeader tag={a.hashtag} events={a.posts} className={classNames("bb", { p: !short })} />;
|
||||
return <HashTagHeader key={a.hashtag} tag={a.hashtag} events={a.posts} className={classNames("bb", { p: !short })} />;
|
||||
}
|
||||
})}
|
||||
</>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { EventExt, NostrLink, TaggedNostrEvent } from "@snort/system";
|
||||
import { EventExt, NostrEvent, NostrLink, TaggedNostrEvent } from "@snort/system";
|
||||
import { useReactions } from "@snort/system-react";
|
||||
|
||||
import PageSpinner from "@/Element/PageSpinner";
|
||||
@ -17,7 +17,7 @@ import useLogin from "@/Hooks/useLogin";
|
||||
import useCachedFetch from "@/Hooks/useCachedFetch";
|
||||
import { System } from "@/index";
|
||||
|
||||
export default function TrendingNotes({ count = Infinity, small = false }) {
|
||||
export default function TrendingNotes({ count = Infinity, small = false }: { count: number, small: boolean }) {
|
||||
const api = new NostrBandApi();
|
||||
const { lang } = useLocale();
|
||||
const trendingNotesUrl = api.trendingNotesUrl(lang);
|
||||
@ -27,15 +27,14 @@ export default function TrendingNotes({ count = Infinity, small = false }) {
|
||||
data: trendingNotesData,
|
||||
isLoading,
|
||||
error,
|
||||
} = useCachedFetch(trendingNotesUrl, storageKey, data => {
|
||||
} = useCachedFetch<{ notes: Array<{ event: NostrEvent }> }, Array<NostrEvent>>(trendingNotesUrl, storageKey, data => {
|
||||
return data.notes.map(a => {
|
||||
const ev = a.event;
|
||||
const id = EventExt.createId(ev);
|
||||
if (!System.QueryOptimizer.schnorrVerify(id, ev.sig, ev.pubkey)) {
|
||||
if (!System.Optimizer.schnorrVerify(ev)) {
|
||||
console.error(`Event with invalid sig\n\n${ev}\n\nfrom ${trendingNotesUrl}`);
|
||||
return;
|
||||
}
|
||||
System.HandleEvent(ev);
|
||||
System.HandleEvent(ev as TaggedNostrEvent);
|
||||
return ev;
|
||||
});
|
||||
});
|
||||
|
@ -9,6 +9,7 @@ import { ProxyImg } from "@/Element/ProxyImg";
|
||||
import Modal from "@/Element/Modal";
|
||||
import Username from "@/Element/User/Username";
|
||||
import { findTag } from "@/SnortUtils";
|
||||
import CloseButton from "@/Element/Button/CloseButton";
|
||||
|
||||
export default function BadgeList({ badges }: { badges: TaggedNostrEvent[] }) {
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
const useCachedFetch = (url, storageKey, dataProcessor = data => data) => {
|
||||
const useCachedFetch = <T, R>(url: string, storageKey: string, dataProcessor?: (data: T) => R) => {
|
||||
const cachedData = useMemo(() => {
|
||||
const cached = localStorage.getItem(storageKey);
|
||||
return cached ? JSON.parse(cached) : null;
|
||||
@ -9,24 +9,24 @@ const useCachedFetch = (url, storageKey, dataProcessor = data => data) => {
|
||||
const initialData = cachedData ? cachedData.data : null;
|
||||
const [data, setData] = useState(initialData);
|
||||
const [isLoading, setIsLoading] = useState(!cachedData);
|
||||
const [error, setError] = useState(null);
|
||||
const [error, setError] = useState<Error>();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
setError(undefined);
|
||||
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP error! status: ${res.status}`);
|
||||
}
|
||||
const fetchedData = await res.json();
|
||||
const processedData = dataProcessor(fetchedData);
|
||||
const fetchedData: T = await res.json();
|
||||
const processedData: R = dataProcessor ? dataProcessor(fetchedData) : (fetchedData as unknown as R);
|
||||
setData(processedData);
|
||||
localStorage.setItem(storageKey, JSON.stringify({ data: processedData, timestamp: new Date().getTime() }));
|
||||
} catch (e) {
|
||||
setError(e);
|
||||
setError(e as Error);
|
||||
if (cachedData?.data) {
|
||||
setData(cachedData.data);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ const getExtra = () => {
|
||||
if (isChristmas()) return <span title="Merry Christmas!">🎄</span>;
|
||||
};
|
||||
|
||||
export function LogoHeader({ showText = false }) {
|
||||
export function LogoHeader({ showText = false }: { showText: boolean }) {
|
||||
const { subscriptions } = useLogin();
|
||||
const currentSubscription = getCurrentSubscription(subscriptions);
|
||||
|
||||
|
@ -113,7 +113,7 @@ const WalletBalance = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default function NavSidebar({ narrow = false }) {
|
||||
export default function NavSidebar({ narrow = false }: { narrow: boolean }) {
|
||||
const { publicKey, subscriptions, readonly } = useLogin(s => ({
|
||||
publicKey: s.publicKey,
|
||||
subscriptions: s.subscriptions,
|
||||
@ -147,7 +147,7 @@ export default function NavSidebar({ narrow = false }) {
|
||||
{ "xl:items-start": !narrow, "xl:gap-2": !narrow },
|
||||
"gap-1 flex flex-col items-center text-lg font-bold",
|
||||
)}>
|
||||
<WalletBalance narrow={narrow} />
|
||||
<WalletBalance />
|
||||
{MENU_ITEMS.filter(a => {
|
||||
if ((CONFIG.hideFromNavbar ?? []).includes(a.link)) {
|
||||
return false;
|
||||
|
@ -67,7 +67,7 @@ export default function Index() {
|
||||
);
|
||||
}
|
||||
|
||||
function StalkerModal({ id }) {
|
||||
function StalkerModal({ id }: { id: string }) {
|
||||
return (
|
||||
<div className="stalker" onClick={() => LoginStore.removeSession(id)}>
|
||||
<CloseButton />
|
||||
|
@ -18,7 +18,7 @@ export default function DmWindow({ id }: { id: string }) {
|
||||
return (
|
||||
<div className="flex -space-x-5 mb-2.5">
|
||||
{chat.participants.map(v => (
|
||||
<ProfileImage pubkey={v.id} showUsername={false} />
|
||||
<ProfileImage key={v.id} pubkey={v.id} showUsername={false} />
|
||||
))}
|
||||
{chat.title ?? <FormattedMessage defaultMessage="Secret Group Chat" id="+Vxixo" />}
|
||||
</div>
|
||||
|
@ -54,7 +54,7 @@ export default function MessagesPage() {
|
||||
return (
|
||||
<div className="flex items-center grow pfp-overlap">
|
||||
{cx.participants.map(v => (
|
||||
<ProfileImage pubkey={v.id} link="" showUsername={false} profile={v.profile} />
|
||||
<ProfileImage key={v.id} pubkey={v.id} link="" showUsername={false} profile={v.profile} />
|
||||
))}
|
||||
{cx.title ?? <FormattedMessage defaultMessage="Group Chat" id="eXT2QQ" />}
|
||||
</div>
|
||||
|
@ -38,7 +38,7 @@ export function ZapsProfileTab({ id }: { id: HexKey }) {
|
||||
<FormattedMessage {...messages.Sats} values={{ n: formatShort(zapsTotal) }} />
|
||||
</h2>
|
||||
{zaps.map(z => (
|
||||
<ZapElement showZapped={false} zap={z} />
|
||||
<ZapElement key={z.id} showZapped={false} zap={z} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
@ -105,7 +105,7 @@ export default function WalletPage(props: { showHistory: boolean }) {
|
||||
<div>
|
||||
<select className="w-max" onChange={e => Wallets.switch(e.target.value)} value={walletState.config?.id}>
|
||||
{Wallets.list().map(a => {
|
||||
return <option value={a.id}>{a.info.alias}</option>;
|
||||
return <option value={a.id} key={a.id}>{a.info.alias}</option>;
|
||||
})}
|
||||
</select>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user