kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Make accountLookup work with Nostr
rodzic
b950a7a052
commit
a0a37b7296
|
@ -185,7 +185,7 @@
|
|||
"vite-plugin-require": "^1.1.10",
|
||||
"vite-plugin-static-copy": "^1.0.0",
|
||||
"wicg-inert": "^3.1.1",
|
||||
"zod": "^3.21.4"
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@formatjs/cli": "^6.2.0",
|
||||
|
|
|
@ -22,7 +22,7 @@ function useAccountLookup(acct: string | undefined, opts: UseAccountLookupOpts =
|
|||
|
||||
const { entity: account, isUnauthorized, ...result } = useEntityLookup<Account>(
|
||||
Entities.ACCOUNTS,
|
||||
(account) => account.acct.toLowerCase() === acct?.toLowerCase(),
|
||||
(account) => account.acct.toLowerCase() === acct?.toLowerCase() || account.nostr.npub === acct,
|
||||
() => api.get(`/api/v1/accounts/lookup?acct=${acct}`),
|
||||
{ schema: accountSchema, enabled: !!acct },
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@ const NostrSigninModal: React.FC<INostrSigninModal> = ({ onClose }) => {
|
|||
case 2:
|
||||
return <KeyStep />;
|
||||
case 3:
|
||||
return <AccountStep />;
|
||||
return <AccountStep username={username} />;
|
||||
case 4:
|
||||
return <RegisterStep />;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
import React from 'react';
|
||||
|
||||
import { useAccountLookup } from 'soapbox/api/hooks';
|
||||
import Stack from 'soapbox/components/ui/stack/stack';
|
||||
|
||||
interface IAccountStep {
|
||||
username: string;
|
||||
}
|
||||
|
||||
const AccountStep: React.FC<IAccountStep> = () => {
|
||||
const AccountStep: React.FC<IAccountStep> = ({ username }) => {
|
||||
const { account } = useAccountLookup(username);
|
||||
|
||||
return (
|
||||
<Stack space={3}>
|
||||
account step
|
||||
{JSON.stringify(account, null, 2)}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ const IdentityStep: React.FC<IIdentityStep> = ({ username, setUsername, setStep
|
|||
|
||||
<HStack space={2} alignItems='center' justifyContent='between'>
|
||||
<Button theme='transparent'>Sign up</Button>
|
||||
<Button theme='accent' onClick={() => setStep(2)}>Next</Button>
|
||||
<Button theme='accent' disabled={!username} onClick={() => setStep(3)}>Next</Button>
|
||||
</HStack>
|
||||
</Stack>
|
||||
);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import escapeTextContentForBrowser from 'escape-html';
|
||||
import DOMPurify from 'isomorphic-dompurify';
|
||||
import { NSchema as n } from 'nspec';
|
||||
import z from 'zod';
|
||||
|
||||
import emojify from 'soapbox/features/emoji';
|
||||
|
@ -50,6 +51,9 @@ const baseAccountSchema = z.object({
|
|||
z.string(),
|
||||
z.null(),
|
||||
]).catch(null),
|
||||
nostr: coerceObject({
|
||||
npub: n.bech32().optional().catch(undefined),
|
||||
}),
|
||||
note: contentSchema,
|
||||
/** Fedibird extra settings. */
|
||||
other_settings: z.object({
|
||||
|
|
|
@ -9698,7 +9698,7 @@ yocto-queue@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251"
|
||||
integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==
|
||||
|
||||
zod@^3.21.0, zod@^3.21.4:
|
||||
zod@^3.21.0:
|
||||
version "3.22.3"
|
||||
resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.3.tgz#2fbc96118b174290d94e8896371c95629e87a060"
|
||||
integrity sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==
|
||||
|
|
Ładowanie…
Reference in New Issue