quick signup (iris)

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 "forYouFeed": false
}, },
"signUp": { "signUp": {
"moderation": true, "quickStart": false,
"defaultFollows": ["npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"] "defaultFollows": ["npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"]
}, },
"defaultPreferences": { "defaultPreferences": {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import { unwrap } from "@snort/shared"; import { unwrap } from "@snort/shared";
import { NotEncrypted } from "@snort/system"; import { NotEncrypted } from "@snort/system";
import classNames from "classnames"; import classNames from "classnames";
import { useState } from "react"; import {FormEvent, useContext, useState} from "react";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import { Link, useNavigate } from "react-router-dom"; import { Link, useNavigate } from "react-router-dom";
@ -9,9 +9,10 @@ import AsyncButton from "@/Components/Button/AsyncButton";
import Icon from "@/Components/Icons/Icon"; import Icon from "@/Components/Icons/Icon";
import useLoginHandler from "@/Hooks/useLoginHandler"; import useLoginHandler from "@/Hooks/useLoginHandler";
import { trackEvent } from "@/Utils"; import { trackEvent } from "@/Utils";
import { LoginSessionType, LoginStore } from "@/Utils/Login"; import { generateNewLogin, LoginSessionType, LoginStore } from "@/Utils/Login";
import { NewUserState } from "."; import { NewUserState } from ".";
import { SnortContext } from "@snort/system-react";
const NSEC_NPUB_REGEX = /(nsec1|npub1)[a-zA-Z0-9]{20,65}/gi; const NSEC_NPUB_REGEX = /(nsec1|npub1)[a-zA-Z0-9]{20,65}/gi;
@ -132,8 +133,18 @@ export function SignUp() {
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const navigate = useNavigate(); const navigate = useNavigate();
const [name, setName] = useState(""); 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", { navigate("/login/sign-up/profile", {
state: { state: {
name: name, name: name,
@ -172,7 +183,15 @@ export function SignUp() {
className="new-username" className="new-username"
/> />
<AsyncButton className="primary" disabled={name.length === 0} onClick={onSubmit}> <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> </AsyncButton>
</form> </form>
<div className="flex flex-col g16 items-center"> <div className="flex flex-col g16 items-center">

View File

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

View File

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