This commit is contained in:
2023-05-15 18:38:26 +01:00
parent 167f1c5e65
commit 6ca55309e9
22 changed files with 2933 additions and 3802 deletions

View File

@ -1,11 +1,10 @@
import "./NoteToSelf.css";
import { Link, useNavigate } from "react-router-dom";
import { FormattedMessage } from "react-intl";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faBook, faCertificate } from "@fortawesome/free-solid-svg-icons";
import { profileLink } from "Util";
import messages from "./messages";
import Icon from "Icons/Icon";
export interface NoteToSelfProps {
pubkey: string;
@ -17,7 +16,7 @@ export interface NoteToSelfProps {
function NoteLabel() {
return (
<div>
<FormattedMessage {...messages.NoteToSelf} /> <FontAwesomeIcon icon={faCertificate} size="xs" />
<FormattedMessage {...messages.NoteToSelf} /> <Icon name="book-closed" />
</div>
);
}
@ -35,7 +34,7 @@ export default function NoteToSelf({ pubkey, clickable, className, link }: NoteT
<div className={`nts${className ? ` ${className}` : ""}`}>
<div className="avatar-wrapper">
<div className={`avatar${clickable ? " clickable" : ""}`}>
<FontAwesomeIcon onClick={clickLink} className="note-to-self" icon={faBook} size="2xl" />
<Icon onClick={clickLink} className="note-to-self" name="book-closed" size={48} />
</div>
</div>
<div className="f-grow">

View File

@ -1,33 +1,23 @@
import "./Relay.css";
import { useMemo } from "react";
import { useIntl, FormattedMessage } from "react-intl";
import { FormattedMessage } from "react-intl";
import { useNavigate } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faPlug,
faSquareCheck,
faSquareXmark,
faWifi,
faPlugCircleXmark,
faGear,
faWarning,
} from "@fortawesome/free-solid-svg-icons";
import { RelaySettings } from "@snort/nostr";
import useRelayState from "Feed/RelayState";
import { System } from "System";
import { getRelayName, unixNowMs, unwrap } from "Util";
import messages from "./messages";
import useLogin from "Hooks/useLogin";
import { setRelays } from "Login";
import Icon from "Icons/Icon";
import messages from "./messages";
export interface RelayProps {
addr: string;
}
export default function Relay(props: RelayProps) {
const { formatMessage } = useIntl();
const navigate = useNavigate();
const login = useLogin();
const relaySettings = unwrap(login.relays.item[props.addr] ?? System.Sockets.get(props.addr)?.Settings ?? {});
@ -50,7 +40,7 @@ export default function Relay(props: RelayProps) {
<>
<div className={`relay w-max`}>
<div className={`flex ${state?.connected ? "bg-success" : "bg-error"}`}>
<FontAwesomeIcon icon={faPlug} />
<Icon name="wifi" />
</div>
<div className="f-grow f-col">
<div className="flex mb10">
@ -65,7 +55,7 @@ export default function Relay(props: RelayProps) {
read: relaySettings.read,
})
}>
<FontAwesomeIcon icon={relaySettings.write ? faSquareCheck : faSquareXmark} />
<Icon name={relaySettings.write ? "check" : "close"} size={12} />
</span>
</div>
<div className="f-1">
@ -78,28 +68,15 @@ export default function Relay(props: RelayProps) {
read: !relaySettings.read,
})
}>
<FontAwesomeIcon icon={relaySettings.read ? faSquareCheck : faSquareXmark} />
<Icon name={relaySettings.read ? "check" : "close"} size={12} />
</span>
</div>
</div>
<div className="flex">
<div className="f-grow">
<FontAwesomeIcon icon={faWifi} className="mr5 ml5" />
{latency > 2000
? formatMessage(messages.Seconds, {
n: (latency / 1000).toFixed(0),
})
: formatMessage(messages.Milliseconds, {
n: latency.toLocaleString(),
})}
&nbsp;
<FontAwesomeIcon icon={faPlugCircleXmark} className="mr5 ml5" /> {state?.disconnects}
<FontAwesomeIcon icon={faWarning} className="mr5 ml5" />
{state?.pendingRequests?.length}
</div>
<div className="f-grow"></div>
<div>
<span className="icon-btn" onClick={() => navigate(state?.id ?? "")}>
<FontAwesomeIcon icon={faGear} />
<Icon name="gear" size={12} />
</span>
</div>
</div>

View File

@ -3,7 +3,7 @@ import { useIntl } from "react-intl";
import { EmailRegex, MnemonicRegex } from "Const";
import { LoginStore } from "Login";
import { generateBip39Entropy, entropyToPrivateKey } from "nip6";
import { getNip05PubKey } from "Pages/Login";
import { getNip05PubKey } from "Pages/LoginPage";
import { bech32ToHex } from "Util";
export default function useLoginHandler() {

View File

@ -1,4 +1,5 @@
import { MouseEventHandler } from "react";
import IconsSvg from "public/icons.svg";
type Props = {
name: string;
@ -9,7 +10,7 @@ type Props = {
const Icon = (props: Props) => {
const size = props.size || 20;
const href = "/icons.svg#" + props.name;
const href = `${IconsSvg}#` + props.name;
return (
<svg width={size} height={size} className={props.className} onClick={props.onClick}>

View File

@ -1,4 +1,4 @@
import "./Login.css";
import "./LoginPage.css";
import { CSSProperties, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";

View File

@ -5,7 +5,7 @@ import { useNavigate, useParams } from "react-router-dom";
import Spinner from "Icons/Spinner";
import { parseNostrLink, profileLink } from "Util";
import { getNip05PubKey } from "Pages/Login";
import { getNip05PubKey } from "Pages/LoginPage";
import { System } from "System";
export default function NostrLinkHandler() {

View File

@ -42,7 +42,7 @@ import BadgeList from "Element/BadgeList";
import { ProxyImg } from "Element/ProxyImg";
import useHorizontalScroll from "Hooks/useHorizontalScroll";
import { EmailRegex } from "Const";
import { getNip05PubKey } from "Pages/Login";
import { getNip05PubKey } from "Pages/LoginPage";
import { LNURL } from "LNURL";
import useLogin from "Hooks/useLogin";

View File

@ -3,14 +3,13 @@ import "./WalletPage.css";
import { useEffect, useState } from "react";
import { RouteObject, useNavigate } from "react-router-dom";
import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCheck, faClock, faXmark } from "@fortawesome/free-solid-svg-icons";
import NoteTime from "Element/NoteTime";
import { WalletInvoice, Sats, WalletInfo, WalletInvoiceState, useWallet, LNWallet, Wallets, WalletKind } from "Wallet";
import AsyncButton from "Element/AsyncButton";
import { unwrap } from "Util";
import { WebLNWallet } from "Wallet/WebLN";
import Icon from "Icons/Icon";
export const WalletRoutes: RouteObject[] = [
{
@ -63,11 +62,11 @@ export default function WalletPage() {
function stateIcon(s: WalletInvoiceState) {
switch (s) {
case WalletInvoiceState.Pending:
return <FontAwesomeIcon icon={faClock} className="mr5" />;
return <Icon name="clock" className="mr5" />;
case WalletInvoiceState.Paid:
return <FontAwesomeIcon icon={faCheck} className="mr5" />;
return <Icon name="check" className="mr5" />;
case WalletInvoiceState.Expired:
return <FontAwesomeIcon icon={faXmark} className="mr5" />;
return <Icon name="close" className="mr5" />;
}
}

View File

@ -3,8 +3,6 @@ import Nostrich from "nostrich.webp";
import { useEffect, useState } from "react";
import { FormattedMessage } from "react-intl";
import { useNavigate } from "react-router-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faShop } from "@fortawesome/free-solid-svg-icons";
import useEventPublisher from "Feed/EventPublisher";
import { useUserProfile } from "Hooks/useUserProfile";
@ -13,9 +11,10 @@ import useFileUpload from "Upload";
import AsyncButton from "Element/AsyncButton";
import { mapEventToProfile, UserCache } from "Cache";
import useLogin from "Hooks/useLogin";
import AvatarEditor from "Element/AvatarEditor";
import Icon from "Icons/Icon";
import messages from "./messages";
import AvatarEditor from "Element/AvatarEditor";
export interface ProfileSettingsProps {
avatar?: boolean;
@ -147,7 +146,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
<div>
<input type="text" className="mr10" value={nip05} onChange={e => setNip05(e.target.value)} />
<button type="button" onClick={() => navigate("/verification")}>
<FontAwesomeIcon icon={faShop} />
<Icon name="shopping-bag" />
&nbsp; <FormattedMessage {...messages.Buy} />
</button>
</div>

View File

@ -1,4 +1,4 @@
import { Connection, RawEvent } from "@snort/nostr";
import { Connection, EventKind, RawEvent } from "@snort/nostr";
import { EventBuilder } from "System";
import { EventExt } from "System/EventExt";
import { LNWallet, WalletError, WalletErrorCode, WalletInfo, WalletInvoice, WalletInvoiceState } from "Wallet";
@ -156,7 +156,7 @@ export class NostrConnectWallet implements LNWallet {
params,
});
const eb = new EventBuilder();
eb.kind(23194)
eb.kind(23194 as EventKind)
.content(await EventExt.encryptData(payload, this.#config.walletPubkey, this.#config.secret))
.tag(["p", this.#config.walletPubkey]);
@ -166,7 +166,7 @@ export class NostrConnectWallet implements LNWallet {
"REQ",
evCommand.id.slice(0, 12),
{
kinds: [23195],
kinds: [23195 as EventKind],
authors: [this.#config.walletPubkey],
["#e"]: [evCommand.id],
},

View File

@ -1,5 +1,6 @@
import "./index.css";
import "@szhsin/react-menu/dist/index.css";
import "public/manifest.json";
import { StrictMode } from "react";
import { QueryClient, QueryClientProvider } from "react-query";
@ -12,7 +13,7 @@ import { IntlProvider } from "IntlProvider";
import { unwrap } from "Util";
import Store from "State/Store";
import Layout from "Pages/Layout";
import LoginPage from "Pages/Login";
import LoginPage from "Pages/LoginPage";
import ProfilePage from "Pages/ProfilePage";
import { RootRoutes } from "Pages/Root";
import NotificationsPage from "Pages/Notifications";