Display the onboarding flow to new Nostr users
This commit is contained in:
parent
af9bb284fa
commit
93a5eef9c6
|
@ -2,11 +2,12 @@ import { RootState, type AppDispatch } from 'soapbox/store';
|
||||||
|
|
||||||
import { authLoggedIn, verifyCredentials } from './auth';
|
import { authLoggedIn, verifyCredentials } from './auth';
|
||||||
import { obtainOAuthToken } from './oauth';
|
import { obtainOAuthToken } from './oauth';
|
||||||
|
import { startOnboarding } from './onboarding';
|
||||||
|
|
||||||
const NOSTR_PUBKEY_SET = 'NOSTR_PUBKEY_SET';
|
const NOSTR_PUBKEY_SET = 'NOSTR_PUBKEY_SET';
|
||||||
|
|
||||||
/** Log in with a Nostr pubkey. */
|
/** Log in with a Nostr pubkey. */
|
||||||
function logInNostr(pubkey: string) {
|
function logInNostr(pubkey: string, onboard = false) {
|
||||||
return async (dispatch: AppDispatch, getState: () => RootState) => {
|
return async (dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
dispatch(setNostrPubkey(pubkey));
|
dispatch(setNostrPubkey(pubkey));
|
||||||
|
|
||||||
|
@ -27,6 +28,10 @@ function logInNostr(pubkey: string) {
|
||||||
secret,
|
secret,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (onboard) {
|
||||||
|
dispatch(startOnboarding());
|
||||||
|
}
|
||||||
|
|
||||||
const { access_token } = dispatch(authLoggedIn(token));
|
const { access_token } = dispatch(authLoggedIn(token));
|
||||||
return await dispatch(verifyCredentials(access_token as string));
|
return await dispatch(verifyCredentials(access_token as string));
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ const OnboardingWizard = () => {
|
||||||
<SuggestedAccountsStep onNext={handleNextStep} />,
|
<SuggestedAccountsStep onNext={handleNextStep} />,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (features.federating){
|
if (features.federating && !features.nostr) {
|
||||||
steps.push(<FediverseStep onNext={handleNextStep} />);
|
steps.push(<FediverseStep onNext={handleNextStep} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ const KeygenStep: React.FC<IKeygenStep> = ({ onClose }) => {
|
||||||
const handleNext = async () => {
|
const handleNext = async () => {
|
||||||
const signer = NKeys.add(secretKey);
|
const signer = NKeys.add(secretKey);
|
||||||
const pubkey = await signer.getPublicKey();
|
const pubkey = await signer.getPublicKey();
|
||||||
dispatch(logInNostr(pubkey));
|
dispatch(logInNostr(pubkey, true));
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue