polish
This commit is contained in:
@@ -34,7 +34,7 @@ export function User({ pubkey, fallback }: { pubkey: string; fallback?: string }
|
|||||||
<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="max-w-[15rem] truncate text-base leading-tight text-zinc-400">
|
||||||
{user?.nip05?.toLowerCase() || shortenKey(pubkey)}
|
{user?.nip05?.toLowerCase() || shortenKey(pubkey)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,12 +24,13 @@ export function CreateStep3Screen() {
|
|||||||
formState: { isDirty, isValid },
|
formState: { isDirty, isValid },
|
||||||
} = useForm();
|
} = useForm();
|
||||||
|
|
||||||
const onSubmit = (data: any) => {
|
const onSubmit = (data: { name: string; about: string }) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const profile = {
|
const profile = {
|
||||||
...data,
|
...data,
|
||||||
username: data.name,
|
username: data.name,
|
||||||
|
name: data.name,
|
||||||
display_name: data.name,
|
display_name: data.name,
|
||||||
bio: data.about,
|
bio: data.about,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function OnboardingScreen() {
|
|||||||
|
|
||||||
// publish event
|
// publish event
|
||||||
publish({
|
publish({
|
||||||
content: 'Running Lume, join with me: https://lume.nu',
|
content: 'Running Lume, join with me #nostr #lume : https://lume.nu',
|
||||||
kind: 1,
|
kind: 1,
|
||||||
tags: [],
|
tags: [],
|
||||||
});
|
});
|
||||||
@@ -55,7 +55,7 @@ export function OnboardingScreen() {
|
|||||||
<User pubkey={account.pubkey} time={Math.floor(Date.now() / 1000)} />
|
<User pubkey={account.pubkey} time={Math.floor(Date.now() / 1000)} />
|
||||||
)}
|
)}
|
||||||
<div className="-mt-6 select-text whitespace-pre-line break-words pl-[49px] text-base text-zinc-100">
|
<div className="-mt-6 select-text whitespace-pre-line break-words pl-[49px] text-base text-zinc-100">
|
||||||
<p>Running Lume, join with me</p>
|
<p>Running Lume, join with me #nostr #lume</p>
|
||||||
<a
|
<a
|
||||||
href="https://lume.nu"
|
href="https://lume.nu"
|
||||||
className="font-normal text-fuchsia-500 no-underline hover:text-fuchsia-600"
|
className="font-normal text-fuchsia-500 no-underline hover:text-fuchsia-600"
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export function UserScreen() {
|
|||||||
<NoteKind_1 event={data[virtualRow.index]} />
|
<NoteKind_1 event={data[virtualRow.index]} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
<div className="h-10" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export async function createAccount(
|
|||||||
await createBlock(
|
await createBlock(
|
||||||
0,
|
0,
|
||||||
'Have fun together!',
|
'Have fun together!',
|
||||||
'https://i.nostrimg.com/cf7bdc227592686a0fcefcecb63fa860aab74c3c36dcd1cb6b09530188db7791/file.jpg'
|
'https://void.cat/d/N5KUHEQCVg7SywXUPiJ7yq.jpg'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const getAccount = await getActiveAccount();
|
const getAccount = await getActiveAccount();
|
||||||
|
|||||||
@@ -1,54 +1,18 @@
|
|||||||
import { open } from '@tauri-apps/api/dialog';
|
|
||||||
import { Body, fetch } from '@tauri-apps/api/http';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { LoaderIcon, PlusIcon } from '@shared/icons';
|
import { LoaderIcon, PlusIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { createBlobFromFile } from '@utils/createBlobFromFile';
|
import { useImageUploader } from '@utils/hooks/useUploader';
|
||||||
|
|
||||||
export function AvatarUploader({ setPicture }: { setPicture: any }) {
|
export function AvatarUploader({ setPicture }: { setPicture: any }) {
|
||||||
|
const upload = useImageUploader();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const openFileDialog = async () => {
|
const uploadAvatar = async () => {
|
||||||
const selected: any = await open({
|
const image = await upload(null);
|
||||||
multiple: false,
|
if (image.url) {
|
||||||
filters: [
|
|
||||||
{
|
|
||||||
name: 'Image',
|
|
||||||
extensions: ['png', 'jpeg', 'jpg', 'gif'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
if (Array.isArray(selected)) {
|
|
||||||
// user selected multiple files
|
|
||||||
} else if (selected === null) {
|
|
||||||
// user cancelled the selection
|
|
||||||
} else {
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
const filename = selected.split('/').pop();
|
|
||||||
const file = await createBlobFromFile(selected);
|
|
||||||
const buf = await file.arrayBuffer();
|
|
||||||
|
|
||||||
const res: { data: { file: { id: string } } } = await fetch(
|
|
||||||
'https://void.cat/upload?cli=false',
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
timeout: 5,
|
|
||||||
headers: {
|
|
||||||
accept: '*/*',
|
|
||||||
'Content-Type': 'application/octet-stream',
|
|
||||||
'V-Filename': filename,
|
|
||||||
'V-Description': 'Upload from https://lume.nu',
|
|
||||||
'V-Strip-Metadata': 'true',
|
|
||||||
},
|
|
||||||
body: Body.bytes(buf),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const image = `https://void.cat/d/${res.data.file.id}.jpg`;
|
|
||||||
|
|
||||||
// update parent state
|
// update parent state
|
||||||
setPicture(image);
|
setPicture(image.url);
|
||||||
|
|
||||||
// disable loader
|
// disable loader
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -58,7 +22,7 @@ export function AvatarUploader({ setPicture }: { setPicture: any }) {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => openFileDialog()}
|
onClick={() => uploadAvatar()}
|
||||||
className="inline-flex h-full w-full items-center justify-center bg-zinc-900/40"
|
className="inline-flex h-full w-full items-center justify-center bg-zinc-900/40"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
|||||||
@@ -1,52 +1,16 @@
|
|||||||
import { open } from '@tauri-apps/api/dialog';
|
|
||||||
import { Body, fetch } from '@tauri-apps/api/http';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { LoaderIcon, PlusIcon } from '@shared/icons';
|
import { LoaderIcon, PlusIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { createBlobFromFile } from '@utils/createBlobFromFile';
|
import { useImageUploader } from '@utils/hooks/useUploader';
|
||||||
|
|
||||||
export function BannerUploader({ setBanner }: { setBanner: any }) {
|
export function BannerUploader({ setBanner }: { setBanner: any }) {
|
||||||
|
const upload = useImageUploader();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const openFileDialog = async () => {
|
const uploadBanner = async () => {
|
||||||
const selected: any = await open({
|
const image = await upload(null);
|
||||||
multiple: false,
|
if (image.url) {
|
||||||
filters: [
|
|
||||||
{
|
|
||||||
name: 'Image',
|
|
||||||
extensions: ['png', 'jpeg', 'jpg', 'gif'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
if (Array.isArray(selected)) {
|
|
||||||
// user selected multiple files
|
|
||||||
} else if (selected === null) {
|
|
||||||
// user cancelled the selection
|
|
||||||
} else {
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
const filename = selected.split('/').pop();
|
|
||||||
const file = await createBlobFromFile(selected);
|
|
||||||
const buf = await file.arrayBuffer();
|
|
||||||
|
|
||||||
const res: { data: { file: { id: string } } } = await fetch(
|
|
||||||
'https://void.cat/upload?cli=false',
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
timeout: 5,
|
|
||||||
headers: {
|
|
||||||
accept: '*/*',
|
|
||||||
'Content-Type': 'application/octet-stream',
|
|
||||||
'V-Filename': filename,
|
|
||||||
'V-Description': 'Upload from https://lume.nu',
|
|
||||||
'V-Strip-Metadata': 'true',
|
|
||||||
},
|
|
||||||
body: Body.bytes(buf),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const image = `https://void.cat/d/${res.data.file.id}.jpg`;
|
|
||||||
|
|
||||||
// update parent state
|
// update parent state
|
||||||
setBanner(image);
|
setBanner(image);
|
||||||
|
|
||||||
@@ -58,7 +22,7 @@ export function BannerUploader({ setBanner }: { setBanner: any }) {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => openFileDialog()}
|
onClick={() => uploadBanner()}
|
||||||
className="inline-flex h-full w-full items-center justify-center bg-zinc-900/40"
|
className="inline-flex h-full w-full items-center justify-center bg-zinc-900/40"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
|||||||
@@ -312,6 +312,20 @@ export function EditProfileModal() {
|
|||||||
className="relative h-10 w-full rounded-lg bg-zinc-800 px-3 py-2 text-zinc-100 !outline-none placeholder:text-zinc-500"
|
className="relative h-10 w-full rounded-lg bg-zinc-800 px-3 py-2 text-zinc-100 !outline-none placeholder:text-zinc-500"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<label
|
||||||
|
htmlFor="website"
|
||||||
|
className="text-sm font-semibold uppercase tracking-wider text-zinc-400"
|
||||||
|
>
|
||||||
|
Lightning address
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type={'text'}
|
||||||
|
{...register('lud16', { required: false })}
|
||||||
|
spellCheck={false}
|
||||||
|
className="relative h-10 w-full rounded-lg bg-zinc-800 px-3 py-2 text-zinc-100 !outline-none placeholder:text-zinc-500"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -1,57 +1,20 @@
|
|||||||
import * as Tooltip from '@radix-ui/react-tooltip';
|
import * as Tooltip from '@radix-ui/react-tooltip';
|
||||||
import { open } from '@tauri-apps/api/dialog';
|
import { open } from '@tauri-apps/api/dialog';
|
||||||
import { Body, fetch } from '@tauri-apps/api/http';
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { LoaderIcon, MediaIcon } from '@shared/icons';
|
import { LoaderIcon, MediaIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { createBlobFromFile } from '@utils/createBlobFromFile';
|
import { useImageUploader } from '@utils/hooks/useUploader';
|
||||||
|
|
||||||
export function MediaUploader({ setState }: { setState: any }) {
|
export function MediaUploader({ setState }: { setState: any }) {
|
||||||
|
const upload = useImageUploader();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const openFileDialog = async () => {
|
const uploadMedia = async () => {
|
||||||
const selected: any = await open({
|
const image = await upload(null);
|
||||||
multiple: false,
|
if (image.url) {
|
||||||
filters: [
|
|
||||||
{
|
|
||||||
name: 'Image & Video',
|
|
||||||
extensions: ['png', 'jpeg', 'jpg', 'gif', 'mp4', 'mov'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
if (Array.isArray(selected)) {
|
|
||||||
// user selected multiple files
|
|
||||||
} else if (selected === null) {
|
|
||||||
// user cancelled the selection
|
|
||||||
} else {
|
|
||||||
// start loading
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
const filename = selected.split('/').pop();
|
|
||||||
const file = await createBlobFromFile(selected);
|
|
||||||
const buf = await file.arrayBuffer();
|
|
||||||
|
|
||||||
const res: { data: { file: { id: string } } } = await fetch(
|
|
||||||
'https://void.cat/upload?cli=false',
|
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
timeout: 5,
|
|
||||||
headers: {
|
|
||||||
accept: '*/*',
|
|
||||||
'Content-Type': 'application/octet-stream',
|
|
||||||
'V-Filename': filename,
|
|
||||||
'V-Description': 'Upload from https://lume.nu',
|
|
||||||
'V-Strip-Metadata': 'true',
|
|
||||||
},
|
|
||||||
body: Body.bytes(buf),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const image = `https://void.cat/d/${res.data.file.id}.webp`;
|
|
||||||
|
|
||||||
// update state
|
// update state
|
||||||
setState((prev: string) => `${prev}\n${image}`);
|
setState((prev: string) => `${prev}\n${image.url}`);
|
||||||
// stop loading
|
// stop loading
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -63,7 +26,7 @@ export function MediaUploader({ setState }: { setState: any }) {
|
|||||||
<Tooltip.Trigger asChild>
|
<Tooltip.Trigger asChild>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => openFileDialog()}
|
onClick={() => uploadMedia()}
|
||||||
className="group inline-flex h-6 w-6 items-center justify-center rounded bg-zinc-700 hover:bg-zinc-600"
|
className="group inline-flex h-6 w-6 items-center justify-center rounded bg-zinc-700 hover:bg-zinc-600"
|
||||||
>
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { NoteZap } from '@shared/notes/actions/zap';
|
|||||||
|
|
||||||
import { BLOCK_KINDS } from '@stores/constants';
|
import { BLOCK_KINDS } from '@stores/constants';
|
||||||
|
|
||||||
|
import { useAccount } from '@utils/hooks/useAccount';
|
||||||
import { useBlock } from '@utils/hooks/useBlock';
|
import { useBlock } from '@utils/hooks/useBlock';
|
||||||
|
|
||||||
export function NoteActions({
|
export function NoteActions({
|
||||||
@@ -22,6 +23,7 @@ export function NoteActions({
|
|||||||
root?: string;
|
root?: string;
|
||||||
}) {
|
}) {
|
||||||
const { add } = useBlock();
|
const { add } = useBlock();
|
||||||
|
const { account } = useAccount();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip.Provider>
|
<Tooltip.Provider>
|
||||||
@@ -30,7 +32,7 @@ export function NoteActions({
|
|||||||
<NoteReply id={id} pubkey={pubkey} root={root} />
|
<NoteReply id={id} pubkey={pubkey} root={root} />
|
||||||
<NoteReaction id={id} pubkey={pubkey} />
|
<NoteReaction id={id} pubkey={pubkey} />
|
||||||
<NoteRepost id={id} pubkey={pubkey} />
|
<NoteRepost id={id} pubkey={pubkey} />
|
||||||
<NoteZap id={id} />
|
{(account?.lud06 || account?.lud16) && <NoteZap id={id} />}
|
||||||
</div>
|
</div>
|
||||||
{!noOpenThread && (
|
{!noOpenThread && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export function NoteZap({ id }: { id: string }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createZapRequest = async () => {
|
const createZapRequest = async () => {
|
||||||
const res = await createZap(event as NostrEvent, amount);
|
const res = await createZap(event as unknown as NostrEvent, amount);
|
||||||
if (res) setInvoice(res);
|
if (res) setInvoice(res);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { Navigate } from 'react-router-dom';
|
import { Navigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { LoaderIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { useStronghold } from '@stores/stronghold';
|
import { useStronghold } from '@stores/stronghold';
|
||||||
|
|
||||||
import { useAccount } from '@utils/hooks/useAccount';
|
import { useAccount } from '@utils/hooks/useAccount';
|
||||||
@@ -9,15 +11,23 @@ export function Protected({ children }: { children: ReactNode }) {
|
|||||||
const privkey = useStronghold((state) => state.privkey);
|
const privkey = useStronghold((state) => state.privkey);
|
||||||
const { status, account } = useAccount();
|
const { status, account } = useAccount();
|
||||||
|
|
||||||
if (status === 'success' && !account) {
|
if (status === 'loading') {
|
||||||
|
return (
|
||||||
|
<div className="flex h-full w-full items-center justify-center">
|
||||||
|
<LoaderIcon className="h-6 w-6 animate-spin text-zinc-100" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!account) {
|
||||||
return <Navigate to="/auth/welcome" replace />;
|
return <Navigate to="/auth/welcome" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status === 'success' && account && account.privkey.length > 35) {
|
if (account && account.privkey.length > 35) {
|
||||||
return <Navigate to="/auth/migrate" replace />;
|
return <Navigate to="/auth/migrate" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status === 'success' && account && !privkey) {
|
if (account && !privkey) {
|
||||||
return <Navigate to="/auth/unlock" replace />;
|
return <Navigate to="/auth/unlock" replace />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
|
import { useNDK } from '@libs/ndk/provider';
|
||||||
import { getActiveAccount } from '@libs/storage';
|
import { getActiveAccount } from '@libs/storage';
|
||||||
|
|
||||||
export function useAccount() {
|
export function useAccount() {
|
||||||
|
const { ndk } = useNDK();
|
||||||
const { status, data: account } = useQuery(
|
const { status, data: account } = useQuery(
|
||||||
['currentAccount'],
|
['currentAccount'],
|
||||||
async () => await getActiveAccount(),
|
async () => {
|
||||||
|
const account = await getActiveAccount();
|
||||||
|
if (account?.pubkey) {
|
||||||
|
const user = ndk.getUser({ hexpubkey: account?.pubkey });
|
||||||
|
await user.fetchProfile();
|
||||||
|
return { ...account, ...user.profile };
|
||||||
|
}
|
||||||
|
return account;
|
||||||
|
},
|
||||||
{
|
{
|
||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
refetchOnMount: true,
|
refetchOnMount: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user