chore: formatting
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
Kieran 2023-11-01 00:40:57 +09:00
parent c65bb7a992
commit 6f15580682
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
13 changed files with 100 additions and 79 deletions

View File

@ -60,4 +60,4 @@ declare const CONFIG: {
/** /**
* Single relay (Debug) * Single relay (Debug)
*/ */
declare const SINGLE_RELAY: string | undefined; declare const SINGLE_RELAY: string | undefined;

View File

@ -2,10 +2,18 @@ import { OfflineError } from "@snort/shared";
import { Offline } from "./Offline"; import { Offline } from "./Offline";
import classNames from "classnames"; import classNames from "classnames";
export function ErrorOrOffline({ error, onRetry, className }: { error: Error, onRetry?: () => void | Promise<void>, className?: string }) { export function ErrorOrOffline({
if (error instanceof OfflineError) { error,
return <Offline onRetry={onRetry} className={className} />; onRetry,
} else { className,
return <b className={classNames("error", className)}>{error.message}</b> }: {
} error: Error;
} onRetry?: () => void | Promise<void>;
className?: string;
}) {
if (error instanceof OfflineError) {
return <Offline onRetry={onRetry} className={className} />;
} else {
return <b className={classNames("error", className)}>{error.message}</b>;
}
}

View File

@ -10,9 +10,7 @@ export default function Reveal(props: RevealProps) {
const [reveal, setReveal] = useState(false); const [reveal, setReveal] = useState(false);
if (!reveal) { if (!reveal) {
return <WarningNotice onClick={() => setReveal(true)}> return <WarningNotice onClick={() => setReveal(true)}>{props.message}</WarningNotice>;
{props.message}
</WarningNotice>
} else if (props.children) { } else if (props.children) {
return props.children; return props.children;
} }

View File

@ -3,15 +3,18 @@ import AsyncButton from "./AsyncButton";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import classNames from "classnames"; import classNames from "classnames";
export function Offline({ onRetry, className }: { onRetry?: () => void | Promise<void>, className?: string }) { export function Offline({ onRetry, className }: { onRetry?: () => void | Promise<void>; className?: string }) {
return <div className={classNames("flex items-center g8", className)}> return (
<Icon name="wifi-off" className="error" /> <div className={classNames("flex items-center g8", className)}>
<div className="error"> <Icon name="wifi-off" className="error" />
<FormattedMessage defaultMessage="Offline" /> <div className="error">
</div> <FormattedMessage defaultMessage="Offline" />
{onRetry && </div>
<AsyncButton onClick={onRetry}> {onRetry && (
<FormattedMessage defaultMessage="Retry" /> <AsyncButton onClick={onRetry}>
</AsyncButton>} <FormattedMessage defaultMessage="Retry" />
</AsyncButton>
)}
</div> </div>
} );
}

View File

@ -1,18 +1,17 @@
.warning-notice { .warning-notice {
color: var(--font-tertiary-color); color: var(--font-tertiary-color);
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
padding: 8px 16px; padding: 8px 16px;
border-radius: 12px; border-radius: 12px;
display: flex; display: flex;
gap: 8px; gap: 8px;
} }
.warning-notice i { .warning-notice i {
font-style: normal; font-style: normal;
color: var(--font-color); color: var(--font-color);
} }
.warning-notice > svg { .warning-notice > svg {
color: var(--warning); color: var(--warning);
} }

View File

@ -1,12 +1,16 @@
import "./WarningNotice.css"; import "./WarningNotice.css";
import Icon from "Icons/Icon"; import Icon from "Icons/Icon";
export function WarningNotice({ children, onClick }: { children: React.ReactNode, onClick?: () => void }) { export function WarningNotice({ children, onClick }: { children: React.ReactNode; onClick?: () => void }) {
return <div className="warning-notice" onClick={e => { return (
<div
className="warning-notice"
onClick={e => {
e.stopPropagation(); e.stopPropagation();
onClick?.(); onClick?.();
}}> }}>
<Icon name="alert-circle" size={24} /> <Icon name="alert-circle" size={24} />
<div>{children}</div> <div>{children}</div>
</div> </div>
} );
}

View File

@ -9,8 +9,7 @@ export function useLoginRelays() {
useEffect(() => { useEffect(() => {
if (relays) { if (relays) {
updateRelayConnections(system, relays.item) updateRelayConnections(system, relays.item).catch(console.error);
.catch(console.error);
} }
}, [relays]); }, [relays]);
} }
@ -28,4 +27,4 @@ export async function updateRelayConnections(system: SystemInterface, relays: Re
} }
} }
} }
} }

View File

@ -187,14 +187,14 @@ export default function ProfilePage({ id: propId, state }: ProfilePageProps) {
targets={ targets={
lnurl?.lnurl && id lnurl?.lnurl && id
? [ ? [
{ {
type: "lnurl", type: "lnurl",
value: lnurl?.lnurl, value: lnurl?.lnurl,
weight: 1, weight: 1,
name: user?.display_name || user?.name, name: user?.display_name || user?.name,
zap: { pubkey: id }, zap: { pubkey: id },
} as ZapTarget, } as ZapTarget,
] ]
: undefined : undefined
} }
show={showLnQr} show={showLnQr}

View File

@ -73,10 +73,7 @@ export const GlobalTab = () => {
return ( return (
<div className="flex items-center g8 justify-end nowrap"> <div className="flex items-center g8 justify-end nowrap">
<h3> <h3>
<FormattedMessage <FormattedMessage defaultMessage="Relay" description="Label for reading global feed from specific relays" />
defaultMessage="Relay"
description="Label for reading global feed from specific relays"
/>
</h3> </h3>
<select <select
className="f-ellipsis" className="f-ellipsis"
@ -126,14 +123,20 @@ export const GlobalTab = () => {
return ( return (
<> <>
{globalRelaySelector()} {globalRelaySelector()}
{relay && <Timeline subject={ {relay && (
{ <Timeline
type: "global", subject={{
items: [], type: "global",
relay: [relay.url], items: [],
discriminator: `all-${sha256(relay.url)}`, relay: [relay.url],
} discriminator: `all-${sha256(relay.url)}`,
} postsOnly={false} method={"TIME_RANGE"} window={600} now={now} />} }}
postsOnly={false}
method={"TIME_RANGE"}
window={600}
now={now}
/>
)}
</> </>
); );
}; };
@ -151,8 +154,8 @@ export const NotesTab = () => {
noteOnClick={ noteOnClick={
deckContext deckContext
? ev => { ? ev => {
deckContext.setThread(NostrLink.fromEvent(ev)); deckContext.setThread(NostrLink.fromEvent(ev));
} }
: undefined : undefined
} }
/> />

View File

@ -32,8 +32,8 @@ export default function ManageSubscriptionPage() {
loadSubs(); loadSubs();
}, []); }, []);
if (!(error instanceof SubscriptionError) && error instanceof Error)
if (!(error instanceof SubscriptionError) && error instanceof Error) return <ErrorOrOffline error={error} onRetry={loadSubs} className="main-content p" />; return <ErrorOrOffline error={error} onRetry={loadSubs} className="main-content p" />;
if (subs === undefined) { if (subs === undefined) {
return <PageSpinner />; return <PageSpinner />;
} }

View File

@ -136,8 +136,7 @@ async function initSite() {
await preload(login.follows.item); await preload(login.follows.item);
} }
updateRelayConnections(System, login.relays.item) updateRelayConnections(System, login.relays.item).catch(console.error);
.catch(console.error);
try { try {
if ("registerProtocolHandler" in window.navigator) { if ("registerProtocolHandler" in window.navigator) {

View File

@ -205,6 +205,9 @@
"6/hB3S": { "6/hB3S": {
"defaultMessage": "Watch Replay" "defaultMessage": "Watch Replay"
}, },
"62nsdy": {
"defaultMessage": "Retry"
},
"65BmHb": { "65BmHb": {
"defaultMessage": "Failed to proxy image from {host}, click here to load directly" "defaultMessage": "Failed to proxy image from {host}, click here to load directly"
}, },
@ -235,6 +238,9 @@
"7BX/yC": { "7BX/yC": {
"defaultMessage": "Account Switcher" "defaultMessage": "Account Switcher"
}, },
"7UOvbT": {
"defaultMessage": "Offline"
},
"7hp70g": { "7hp70g": {
"defaultMessage": "NIP-05" "defaultMessage": "NIP-05"
}, },
@ -594,6 +600,10 @@
"KAhAcM": { "KAhAcM": {
"defaultMessage": "Enter LNDHub config" "defaultMessage": "Enter LNDHub config"
}, },
"KHK8B9": {
"defaultMessage": "Relay",
"description": "Label for reading global feed from specific relays"
},
"KQvWvD": { "KQvWvD": {
"defaultMessage": "Deleted" "defaultMessage": "Deleted"
}, },
@ -1554,10 +1564,6 @@
"yCLnBC": { "yCLnBC": {
"defaultMessage": "LNURL or Lightning Address" "defaultMessage": "LNURL or Lightning Address"
}, },
"yCmnnm": {
"defaultMessage": "Read global from",
"description": "Label for reading global feed from specific relays"
},
"yNBPJp": { "yNBPJp": {
"defaultMessage": "Help fund the development of {site}" "defaultMessage": "Help fund the development of {site}"
}, },

View File

@ -67,6 +67,7 @@
"5ykRmX": "Send zap", "5ykRmX": "Send zap",
"6/SF6e": "<h1>{n}</h1> Cashu sats", "6/SF6e": "<h1>{n}</h1> Cashu sats",
"6/hB3S": "Watch Replay", "6/hB3S": "Watch Replay",
"62nsdy": "Retry",
"65BmHb": "Failed to proxy image from {host}, click here to load directly", "65BmHb": "Failed to proxy image from {host}, click here to load directly",
"6OSOXl": "Reason: <i>{reason}</i>", "6OSOXl": "Reason: <i>{reason}</i>",
"6TfgXX": "{site} is an open source project built by passionate people in their free time", "6TfgXX": "{site} is an open source project built by passionate people in their free time",
@ -77,6 +78,7 @@
"7+Domh": "Notes", "7+Domh": "Notes",
"7/h1jn": "After submitting the pin there may be a slight delay as we encrypt the key.", "7/h1jn": "After submitting the pin there may be a slight delay as we encrypt the key.",
"7BX/yC": "Account Switcher", "7BX/yC": "Account Switcher",
"7UOvbT": "Offline",
"7hp70g": "NIP-05", "7hp70g": "NIP-05",
"8/vBbP": "Reposts ({n})", "8/vBbP": "Reposts ({n})",
"89q5wc": "Confirm Reposts", "89q5wc": "Confirm Reposts",
@ -195,6 +197,7 @@
"K3r6DQ": "Delete", "K3r6DQ": "Delete",
"K7AkdL": "Show", "K7AkdL": "Show",
"KAhAcM": "Enter LNDHub config", "KAhAcM": "Enter LNDHub config",
"KHK8B9": "Relay",
"KQvWvD": "Deleted", "KQvWvD": "Deleted",
"KWuDfz": "I have saved my keys, continue", "KWuDfz": "I have saved my keys, continue",
"KahimY": "Unknown event kind: {kind}", "KahimY": "Unknown event kind: {kind}",
@ -509,7 +512,6 @@
"xmcVZ0": "Search", "xmcVZ0": "Search",
"y1Z3or": "Language", "y1Z3or": "Language",
"yCLnBC": "LNURL or Lightning Address", "yCLnBC": "LNURL or Lightning Address",
"yCmnnm": "Read global from",
"yNBPJp": "Help fund the development of {site}", "yNBPJp": "Help fund the development of {site}",
"zCb8fX": "Weight", "zCb8fX": "Weight",
"zFegDD": "Contact", "zFegDD": "Contact",