mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-19 19:46:34 +00:00
add download keys button to onboarding process
This commit is contained in:
parent
12bfa2fca1
commit
6307e8d1e4
@ -16,7 +16,7 @@ tauri-build = { version = "1.2", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tauri = { version = "1.2", features = [ "window-create", "path-all", "fs-read-dir", "fs-read-file", "clipboard-read-text", "clipboard-write-text", "dialog-open", "http-all", "http-multipart", "notification-all", "os-all", "process-relaunch", "shell-open", "system-tray", "updater", "window-close", "window-start-dragging"] }
|
tauri = { version = "1.2", features = [ "fs-write-file", "window-create", "path-all", "fs-read-dir", "fs-read-file", "clipboard-read-text", "clipboard-write-text", "dialog-open", "http-all", "http-multipart", "notification-all", "os-all", "process-relaunch", "shell-open", "system-tray", "updater", "window-close", "window-start-dragging"] }
|
||||||
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"all": false,
|
"all": false,
|
||||||
"readFile": true,
|
"readFile": true,
|
||||||
"readDir": true,
|
"readDir": true,
|
||||||
|
"writeFile": true,
|
||||||
"scope": [
|
"scope": [
|
||||||
"$APPDATA/*",
|
"$APPDATA/*",
|
||||||
"$DATA/*",
|
"$DATA/*",
|
||||||
|
@ -24,7 +24,7 @@ export function User({ pubkey, fallback }: { pubkey: string; fallback?: string }
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="relative h-10 w-10 shrink rounded-md">
|
<div className="relative h-10 w-10 shrink rounded-md">
|
||||||
<Image
|
<Image
|
||||||
src={user.picture || user.image}
|
src={user?.picture || user?.image}
|
||||||
fallback={DEFAULT_AVATAR}
|
fallback={DEFAULT_AVATAR}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-10 w-10 rounded-md object-cover"
|
className="h-10 w-10 rounded-md object-cover"
|
||||||
@ -32,10 +32,10 @@ export function User({ pubkey, fallback }: { pubkey: string; fallback?: string }
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex w-full flex-1 flex-col items-start text-start">
|
<div className="flex w-full flex-1 flex-col items-start text-start">
|
||||||
<span className="truncate font-medium leading-tight text-zinc-100">
|
<span className="truncate font-medium leading-tight text-zinc-100">
|
||||||
{user.name || user.displayName || user.display_name}
|
{user?.name || user?.displayName || user?.display_name}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-base leading-tight text-zinc-400">
|
<span className="text-base leading-tight text-zinc-400">
|
||||||
{user.nip05?.toLowerCase() || shortenKey(pubkey)}
|
{user?.nip05?.toLowerCase() || shortenKey(pubkey)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
import { BaseDirectory, writeTextFile } from '@tauri-apps/api/fs';
|
||||||
import { generatePrivateKey, getPublicKey, nip19 } from 'nostr-tools';
|
import { generatePrivateKey, getPublicKey, nip19 } from 'nostr-tools';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
@ -19,6 +20,7 @@ export function CreateStep1Screen() {
|
|||||||
|
|
||||||
const [privkeyInput, setPrivkeyInput] = useState('password');
|
const [privkeyInput, setPrivkeyInput] = useState('password');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [downloaded, setDownloaded] = useState(false);
|
||||||
|
|
||||||
const privkey = useMemo(() => generatePrivateKey(), []);
|
const privkey = useMemo(() => generatePrivateKey(), []);
|
||||||
const pubkey = getPublicKey(privkey);
|
const pubkey = getPublicKey(privkey);
|
||||||
@ -34,6 +36,17 @@ export function CreateStep1Screen() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const download = async () => {
|
||||||
|
await writeTextFile(
|
||||||
|
'lume-keys.txt',
|
||||||
|
`Public key: ${pubkey}\nPrivate key: ${privkey}`,
|
||||||
|
{
|
||||||
|
dir: BaseDirectory.Download,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setDownloaded(true);
|
||||||
|
};
|
||||||
|
|
||||||
const account = useMutation({
|
const account = useMutation({
|
||||||
mutationFn: (data: {
|
mutationFn: (data: {
|
||||||
npub: string;
|
npub: string;
|
||||||
@ -68,9 +81,7 @@ export function CreateStep1Screen() {
|
|||||||
return (
|
return (
|
||||||
<div className="mx-auto w-full max-w-md">
|
<div className="mx-auto w-full max-w-md">
|
||||||
<div className="mb-8 text-center">
|
<div className="mb-8 text-center">
|
||||||
<h1 className="text-xl font-semibold text-zinc-100">
|
<h1 className="text-xl font-semibold text-zinc-100">Save your access key!</h1>
|
||||||
Lume is auto-generated key for you
|
|
||||||
</h1>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
@ -110,14 +121,26 @@ export function CreateStep1Screen() {
|
|||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mt-2 text-sm text-zinc-500">
|
||||||
|
<p>
|
||||||
|
Your private key is your password. If you lose this key, you will lose
|
||||||
|
access to your account! Copy it and keep it in a safe place. There is no way
|
||||||
|
to reset your private key.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
<Button preset="large" onClick={() => submit()}>
|
<Button preset="large" onClick={() => submit()}>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<LoaderIcon className="h-4 w-4 animate-spin text-black dark:text-zinc-100" />
|
<LoaderIcon className="h-4 w-4 animate-spin text-black dark:text-zinc-100" />
|
||||||
) : (
|
) : (
|
||||||
'Continue →'
|
'I have saved my key, continue →'
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button preset="large-alt" onClick={() => download()}>
|
||||||
|
{downloaded ? 'Saved in Download folder' : 'Download'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -37,15 +37,16 @@ export function OnboardingScreen() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full items-center justify-center">
|
<div className="flex h-full w-full items-center justify-center">
|
||||||
<div className="mx-auto w-full max-w-md">
|
<div className="mx-auto w-full max-w-md">
|
||||||
<div className="mb-8 text-center">
|
<div className="mb-4 text-center">
|
||||||
<h1 className="mb-2 text-xl font-semibold text-zinc-100">
|
<h1 className="mb-2 text-xl font-semibold text-zinc-100">
|
||||||
👋 Hello, welcome you to Lume
|
👋 Hello, welcome you to Lume
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-sm text-zinc-300">
|
<p className="text-sm text-zinc-300">
|
||||||
You're a part of better future that we're fighting
|
You're a part of Nostr community now
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm text-zinc-300">
|
<p className="text-sm text-zinc-300">
|
||||||
If Lume gets your attention, please help us spread via button below
|
If Lume gets your attention, please help us spread it and don't forget
|
||||||
|
invite your friend join with you, we can have fun togother
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full rounded-xl border-t border-zinc-800/50 bg-zinc-900">
|
<div className="w-full rounded-xl border-t border-zinc-800/50 bg-zinc-900">
|
||||||
@ -84,16 +85,16 @@ export function OnboardingScreen() {
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<span className="w-5" />
|
<span className="w-5" />
|
||||||
<span>Publish</span>
|
<span>Spread</span>
|
||||||
<ArrowRightCircleIcon className="h-5 w-5" />
|
<ArrowRightCircleIcon className="h-5 w-5" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
<Link
|
<Link
|
||||||
to="/"
|
to="/"
|
||||||
className="inline-flex h-10 w-full items-center justify-center gap-2 rounded-lg px-6 text-sm font-medium text-zinc-200"
|
className="inline-flex h-12 w-full items-center justify-center gap-2 rounded-lg bg-zinc-800 px-6 font-medium text-zinc-300 hover:bg-zinc-900"
|
||||||
>
|
>
|
||||||
Skip for now
|
Skip
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -86,7 +86,7 @@ export function FollowingBlock() {
|
|||||||
if (root || reply) {
|
if (root || reply) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={note.event_id || note.id}
|
key={(root || reply) + (note.event_id || note.id)}
|
||||||
data-index={index}
|
data-index={index}
|
||||||
ref={rowVirtualizer.measureElement}
|
ref={rowVirtualizer.measureElement}
|
||||||
>
|
>
|
||||||
|
@ -53,7 +53,7 @@ export async function createAccount(
|
|||||||
if (res) {
|
if (res) {
|
||||||
await createBlock(
|
await createBlock(
|
||||||
0,
|
0,
|
||||||
'Preserve your freedom',
|
'Have fun together!',
|
||||||
'https://void.cat/d/949GNg7ZjSLHm2eTR3jZqv'
|
'https://void.cat/d/949GNg7ZjSLHm2eTR3jZqv'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export function Button({
|
|||||||
disabled = false,
|
disabled = false,
|
||||||
onClick = undefined,
|
onClick = undefined,
|
||||||
}: {
|
}: {
|
||||||
preset: 'small' | 'publish' | 'large';
|
preset: 'small' | 'publish' | 'large' | 'large-alt';
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
@ -26,6 +26,10 @@ export function Button({
|
|||||||
preClass =
|
preClass =
|
||||||
'h-11 w-full bg-fuchsia-500 rounded-md font-medium text-zinc-100 hover:bg-fuchsia-600';
|
'h-11 w-full bg-fuchsia-500 rounded-md font-medium text-zinc-100 hover:bg-fuchsia-600';
|
||||||
break;
|
break;
|
||||||
|
case 'large-alt':
|
||||||
|
preClass =
|
||||||
|
'h-11 w-full bg-zinc-800 rounded-md font-medium text-zinc-300 border-t border-zinc-700/50 hover:bg-zinc-900';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,10 @@ export function useEvent(id: string, fallback?: string) {
|
|||||||
embed.content,
|
embed.content,
|
||||||
embed.created_at
|
embed.created_at
|
||||||
);
|
);
|
||||||
}
|
return embed;
|
||||||
|
} else {
|
||||||
const event = await ndk.fetchEvent(id);
|
const event = await ndk.fetchEvent(id);
|
||||||
|
if (event) {
|
||||||
await createNote(
|
await createNote(
|
||||||
event.id,
|
event.id,
|
||||||
event.pubkey,
|
event.pubkey,
|
||||||
@ -44,12 +46,17 @@ export function useEvent(id: string, fallback?: string) {
|
|||||||
event['content'] = parser(event);
|
event['content'] = parser(event);
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
refetchOnReconnect: false,
|
refetchOnReconnect: false,
|
||||||
|
staleTime: Infinity,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user