quick signup (iris)
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Martti Malmi 2024-02-12 10:43:48 +02:00
parent 248b35d3ca
commit 2d74f55e06
8 changed files with 33 additions and 9 deletions

View File

@ -22,7 +22,7 @@
"forYouFeed": false
},
"signUp": {
"moderation": true,
"quickStart": false,
"defaultFollows": ["npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"]
},
"defaultPreferences": {

View File

@ -23,7 +23,7 @@
"hideMutedNotes": true
},
"signUp": {
"moderation": false,
"quickStart": true,
"defaultFollows": ["npub1wnwwcv0a8wx0m9stck34ajlwhzuua68ts8mw3kjvspn42dcfyjxs4n95l8"]
},
"media": {

View File

@ -21,7 +21,7 @@
"pushNotifications": false
},
"signUp": {
"moderation": true,
"quickStart": false,
"defaultFollows": []
},
"defaultPreferences": {

View File

@ -67,7 +67,7 @@ declare const CONFIG: {
hideMutedNotes: boolean;
};
signUp: {
moderation: boolean;
quickStart: boolean;
defaultFollows: Array<string>;
};
media: {

View File

@ -34,7 +34,7 @@ export function Discover() {
<AsyncButton
className="primary"
onClick={() =>
navigate(CONFIG.signUp.moderation ? "/login/sign-up/moderation" : "/", {
navigate("/login/sign-up/moderation", {
state,
})
}>

View File

@ -1,7 +1,7 @@
import { unwrap } from "@snort/shared";
import { NotEncrypted } from "@snort/system";
import classNames from "classnames";
import { useState } from "react";
import {FormEvent, useContext, useState} from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { Link, useNavigate } from "react-router-dom";
@ -9,9 +9,10 @@ import AsyncButton from "@/Components/Button/AsyncButton";
import Icon from "@/Components/Icons/Icon";
import useLoginHandler from "@/Hooks/useLoginHandler";
import { trackEvent } from "@/Utils";
import { LoginSessionType, LoginStore } from "@/Utils/Login";
import { generateNewLogin, LoginSessionType, LoginStore } from "@/Utils/Login";
import { NewUserState } from ".";
import { SnortContext } from "@snort/system-react";
const NSEC_NPUB_REGEX = /(nsec1|npub1)[a-zA-Z0-9]{20,65}/gi;
@ -132,8 +133,18 @@ export function SignUp() {
const { formatMessage } = useIntl();
const navigate = useNavigate();
const [name, setName] = useState("");
const system = useContext(SnortContext);
const onSubmit = () => {
const onSubmit = async (e: FormEvent) => {
e.preventDefault();
if (CONFIG.signUp.quickStart) {
return generateNewLogin(system, key => Promise.resolve(new NotEncrypted(key)), {
name,
}).then(() => {
trackEvent("Login", { newAccount: true });
navigate("/trending/notes");
});
}
navigate("/login/sign-up/profile", {
state: {
name: name,
@ -172,7 +183,15 @@ export function SignUp() {
className="new-username"
/>
<AsyncButton className="primary" disabled={name.length === 0} onClick={onSubmit}>
<FormattedMessage defaultMessage="Next" id="9+Ddtu" />
{CONFIG.signUp.quickStart ? (
<FormattedMessage
description="Button text after entering username in quick signup"
defaultMessage="Go"
id="0zASjL"
/>
) : (
<FormattedMessage defaultMessage="Next" id="9+Ddtu" />
)}
</AsyncButton>
</form>
<div className="flex flex-col g16 items-center">

View File

@ -93,6 +93,10 @@
"0yO7wF": {
"defaultMessage": "{n} secs"
},
"0zASjL": {
"defaultMessage": "Go",
"description": "Button text after entering username in quick signup"
},
"1H4Keq": {
"defaultMessage": "{n} users"
},

View File

@ -30,6 +30,7 @@
"0siT4z": "Politics",
"0uoY11": "Show Status",
"0yO7wF": "{n} secs",
"0zASjL": "Go",
"1H4Keq": "{n} users",
"1Mo59U": "Are you sure you want to remove this note from bookmarks?",
"1R43+L": "Enter Nostr Wallet Connect config",