Rework nostrExtensionLogIn action
This commit is contained in:
parent
a8e786a578
commit
5bc6a9a220
3 changed files with 10 additions and 6 deletions
|
@ -3,7 +3,6 @@ import { nip19 } from 'nostr-tools';
|
||||||
import { type AppDispatch } from 'soapbox/store';
|
import { type AppDispatch } from 'soapbox/store';
|
||||||
|
|
||||||
import { verifyCredentials } from './auth';
|
import { verifyCredentials } from './auth';
|
||||||
import { closeModal } from './modals';
|
|
||||||
|
|
||||||
/** Log in with a Nostr pubkey. */
|
/** Log in with a Nostr pubkey. */
|
||||||
function logInNostr(pubkey: string) {
|
function logInNostr(pubkey: string) {
|
||||||
|
@ -19,10 +18,7 @@ function nostrExtensionLogIn() {
|
||||||
if (!window.nostr) {
|
if (!window.nostr) {
|
||||||
throw new Error('No Nostr signer available');
|
throw new Error('No Nostr signer available');
|
||||||
}
|
}
|
||||||
|
|
||||||
const pubkey = await window.nostr.getPublicKey();
|
const pubkey = await window.nostr.getPublicKey();
|
||||||
|
|
||||||
dispatch(closeModal('NOSTR_SIGNIN'));
|
|
||||||
return dispatch(logInNostr(pubkey));
|
return dispatch(logInNostr(pubkey));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
import { closeModal } from 'soapbox/actions/modals';
|
||||||
import { nostrExtensionLogIn } from 'soapbox/actions/nostr';
|
import { nostrExtensionLogIn } from 'soapbox/actions/nostr';
|
||||||
import Stack from 'soapbox/components/ui/stack/stack';
|
import Stack from 'soapbox/components/ui/stack/stack';
|
||||||
import Text from 'soapbox/components/ui/text/text';
|
import Text from 'soapbox/components/ui/text/text';
|
||||||
|
@ -9,7 +10,10 @@ import { useAppDispatch } from 'soapbox/hooks';
|
||||||
const NostrExtensionIndicator: React.FC = () => {
|
const NostrExtensionIndicator: React.FC = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const onClick = () => dispatch(nostrExtensionLogIn());
|
const onClick = () => {
|
||||||
|
dispatch(nostrExtensionLogIn());
|
||||||
|
dispatch(closeModal('NOSTR_SIGNIN'));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack space={2} className='rounded-lg bg-gray-100 p-2 dark:bg-gray-800'>
|
<Stack space={2} className='rounded-lg bg-gray-100 p-2 dark:bg-gray-800'>
|
||||||
|
|
|
@ -16,7 +16,11 @@ interface IExtensionStep {
|
||||||
const ExtensionStep: React.FC<IExtensionStep> = ({ setStep, onClose }) => {
|
const ExtensionStep: React.FC<IExtensionStep> = ({ setStep, onClose }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const onClick = () => dispatch(nostrExtensionLogIn());
|
const onClick = () => {
|
||||||
|
dispatch(nostrExtensionLogIn());
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
const onClickAlt = () => setStep('key');
|
const onClickAlt = () => setStep('key');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue