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