chore: only show login dialog if nip-07 extension is not present
This commit is contained in:
@ -10,7 +10,6 @@ import { Icon } from "./icon";
|
||||
import Copy from "./copy";
|
||||
import { hexToBech32, openFile } from "utils";
|
||||
import { VoidApi } from "@void-cat/api";
|
||||
import { LoginType } from "login";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { bech32 } from "@scure/base";
|
||||
|
||||
@ -27,23 +26,6 @@ export function LoginSignup({ close }: { close: () => void }) {
|
||||
const [avatar, setAvatar] = useState("");
|
||||
const [key, setNewKey] = useState("");
|
||||
|
||||
async function doLogin() {
|
||||
try {
|
||||
const pub = await EventPublisher.nip7();
|
||||
if (pub) {
|
||||
Login.loginWithPubkey(pub.pubKey, LoginType.Nip7);
|
||||
close();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
if (e instanceof Error) {
|
||||
setError(e.message);
|
||||
} else {
|
||||
setError(e as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doLoginNsec() {
|
||||
try {
|
||||
let nsec = prompt("Enter your nsec\nWARNING: THIS IS NOT RECOMMENDED. DO NOT IMPORT ANY KEYS YOU CARE ABOUT");
|
||||
@ -118,11 +100,6 @@ export function LoginSignup({ close }: { close: () => void }) {
|
||||
<h2>
|
||||
<FormattedMessage defaultMessage="Login" />
|
||||
</h2>
|
||||
{"nostr" in window && (
|
||||
<AsyncButton type="button" className="btn btn-primary" onClick={doLogin}>
|
||||
<FormattedMessage defaultMessage="Nostr Extension" />
|
||||
</AsyncButton>
|
||||
)}
|
||||
<button type="button" className="btn btn-primary" onClick={createAccount}>
|
||||
<FormattedMessage defaultMessage="Create Account" />
|
||||
</button>
|
||||
|
@ -13,6 +13,8 @@ import { Menu, MenuItem } from "@szhsin/react-menu";
|
||||
import { hexToBech32 } from "@snort/shared";
|
||||
import { Login } from "index";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { EventPublisher } from "@snort/system";
|
||||
import { LoginType } from "login";
|
||||
|
||||
export function LayoutPage() {
|
||||
const navigate = useNavigate();
|
||||
@ -62,14 +64,26 @@ export function LayoutPage() {
|
||||
function loggedOut() {
|
||||
if (login) return;
|
||||
|
||||
async function handleLogin() {
|
||||
try {
|
||||
const pub = await EventPublisher.nip7();
|
||||
if (pub) {
|
||||
Login.loginWithPubkey(pub.pubKey, LoginType.Nip7);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
setShowLogin(true);
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog.Root open={showLogin} onOpenChange={setShowLogin}>
|
||||
<Dialog.Trigger asChild>
|
||||
<button type="button" className="btn btn-border" onClick={() => setShowLogin(true)}>
|
||||
<button type="button" className="btn btn-border" onClick={handleLogin}>
|
||||
<FormattedMessage defaultMessage="Login" />
|
||||
<Icon name="login" />
|
||||
</button>
|
||||
</Dialog.Trigger>
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay className="dialog-overlay" />
|
||||
<Dialog.Content className="dialog-content">
|
||||
|
Reference in New Issue
Block a user