Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d43c13928 | |||
| a42a2788ea | |||
| e30274dab3 | |||
|
|
740b7588bc | ||
| 24c2ed4eb2 | |||
| 4006c0010e | |||
| 7decf264d7 | |||
| 482b218f74 | |||
| e06b760e41 | |||
| 7efc35f622 | |||
| 8795923443 | |||
| 4093821fd0 | |||
| b19637bdb7 | |||
| 21e758ec13 | |||
| 48ab123850 | |||
| a401070031 |
@@ -11,7 +11,6 @@
|
|||||||
"^@app/(.*)$",
|
"^@app/(.*)$",
|
||||||
"^@libs/(.*)$",
|
"^@libs/(.*)$",
|
||||||
"^@shared/(.*)$",
|
"^@shared/(.*)$",
|
||||||
"^@stores/(.*)$",
|
|
||||||
"^@utils/(.*)$",
|
"^@utils/(.*)$",
|
||||||
"^[./]"
|
"^[./]"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Lume</title>
|
<title>Lume</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="relative cursor-default select-none overflow-hidden font-sans antialiased h-screen w-screen text-neutral-950 dark:text-neutral-50">
|
<body
|
||||||
|
class="relative h-screen w-screen cursor-default select-none overflow-hidden font-sans text-neutral-950 antialiased dark:text-neutral-50"
|
||||||
|
>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/src/main.jsx"></script>
|
<script type="module" src="/src/main.jsx"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
25
package.json
25
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "lume",
|
"name": "lume",
|
||||||
"description": "the communication app",
|
"description": "the communication app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.2.0",
|
"version": "2.2.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
"@radix-ui/react-switch": "^1.0.3",
|
"@radix-ui/react-switch": "^1.0.3",
|
||||||
"@radix-ui/react-toolbar": "^1.0.4",
|
"@radix-ui/react-toolbar": "^1.0.4",
|
||||||
"@radix-ui/react-tooltip": "^1.0.7",
|
"@radix-ui/react-tooltip": "^1.0.7",
|
||||||
"@tanstack/react-query": "^5.12.1",
|
"@tanstack/react-query": "^5.12.2",
|
||||||
"@tanstack/react-query-devtools": "^5.12.1",
|
"@tanstack/react-query-devtools": "^5.12.2",
|
||||||
"@tauri-apps/api": "2.0.0-alpha.11",
|
"@tauri-apps/api": "2.0.0-alpha.11",
|
||||||
"@tauri-apps/cli": "2.0.0-alpha.17",
|
"@tauri-apps/cli": "2.0.0-alpha.17",
|
||||||
"@tauri-apps/plugin-autostart": "2.0.0-alpha.3",
|
"@tauri-apps/plugin-autostart": "2.0.0-alpha.3",
|
||||||
@@ -60,16 +60,15 @@
|
|||||||
"@tiptap/react": "^2.1.13",
|
"@tiptap/react": "^2.1.13",
|
||||||
"@tiptap/starter-kit": "^2.1.13",
|
"@tiptap/starter-kit": "^2.1.13",
|
||||||
"@tiptap/suggestion": "^2.1.13",
|
"@tiptap/suggestion": "^2.1.13",
|
||||||
|
"@vidstack/react": "^1.8.3",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"framer-motion": "^10.16.12",
|
"framer-motion": "^10.16.12",
|
||||||
"html-to-text": "^9.0.5",
|
"html-to-text": "^9.0.5",
|
||||||
"idb-keyval": "^6.2.1",
|
|
||||||
"light-bolt11-decoder": "^3.0.0",
|
"light-bolt11-decoder": "^3.0.0",
|
||||||
"lru-cache": "^10.1.0",
|
"lru-cache": "^10.1.0",
|
||||||
"markdown-to-jsx": "^7.3.2",
|
"markdown-to-jsx": "^7.3.2",
|
||||||
"media-chrome": "^1.5.4",
|
|
||||||
"minidenticons": "^4.2.0",
|
"minidenticons": "^4.2.0",
|
||||||
"nanoid": "^5.0.3",
|
"nanoid": "^5.0.4",
|
||||||
"nostr-fetch": "^0.13.1",
|
"nostr-fetch": "^0.13.1",
|
||||||
"nostr-tools": "^1.17.0",
|
"nostr-tools": "^1.17.0",
|
||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
@@ -85,8 +84,8 @@
|
|||||||
"sonner": "^1.2.4",
|
"sonner": "^1.2.4",
|
||||||
"tauri-controls": "github:reyamir/tauri-controls",
|
"tauri-controls": "github:reyamir/tauri-controls",
|
||||||
"tippy.js": "^6.3.7",
|
"tippy.js": "^6.3.7",
|
||||||
"tiptap-markdown": "^0.8.7",
|
"tiptap-markdown": "^0.8.8",
|
||||||
"virtua": "^0.16.7",
|
"virtua": "^0.17.4",
|
||||||
"zustand": "^4.4.7"
|
"zustand": "^4.4.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -94,8 +93,8 @@
|
|||||||
"@tailwindcss/typography": "^0.5.10",
|
"@tailwindcss/typography": "^0.5.10",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||||
"@types/html-to-text": "^9.0.4",
|
"@types/html-to-text": "^9.0.4",
|
||||||
"@types/node": "^20.10.2",
|
"@types/node": "^20.10.3",
|
||||||
"@types/react": "^18.2.40",
|
"@types/react": "^18.2.41",
|
||||||
"@types/react-dom": "^18.2.17",
|
"@types/react-dom": "^18.2.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
||||||
"@typescript-eslint/parser": "^6.13.1",
|
"@typescript-eslint/parser": "^6.13.1",
|
||||||
@@ -105,13 +104,13 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"encoding": "^0.1.13",
|
"encoding": "^0.1.13",
|
||||||
"eslint": "^8.55.0",
|
"eslint": "^8.55.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.8.0",
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.33.2",
|
||||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^15.1.0",
|
"lint-staged": "^15.2.0",
|
||||||
"postcss": "^8.4.31",
|
"postcss": "^8.4.32",
|
||||||
"prettier": "^3.1.0",
|
"prettier": "^3.1.0",
|
||||||
"prettier-plugin-tailwindcss": "^0.5.7",
|
"prettier-plugin-tailwindcss": "^0.5.7",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
|
|||||||
840
pnpm-lock.yaml
generated
840
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace",
|
|||||||
tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-theme = { git = "https://github.com/wyhaya/tauri-plugin-theme" }
|
tauri-plugin-theme = { git = "https://github.com/wyhaya/tauri-plugin-theme" }
|
||||||
tauri-plugin-sql = { git = "hhttps://github.com/tauri-apps/plugins-workspace", branch = "v2", features = [
|
tauri-plugin-sql = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2", features = [
|
||||||
"sqlite",
|
"sqlite",
|
||||||
] }
|
] }
|
||||||
sqlx-cli = { version = "0.7.0", default-features = false, features = [
|
sqlx-cli = { version = "0.7.0", default-features = false, features = [
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "Lume",
|
"productName": "Lume",
|
||||||
"version": "2.2.0"
|
"version": "2.2.2"
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"fs": {
|
"fs": {
|
||||||
|
|||||||
20
src/app.css
20
src/app.css
@@ -1,5 +1,9 @@
|
|||||||
/* @import 'reactflow/dist/style.css'; */
|
/* @import 'reactflow/dist/style.css'; */
|
||||||
|
|
||||||
|
/* Vidstack */
|
||||||
|
@import '@vidstack/react/player/styles/default/theme.css';
|
||||||
|
@import '@vidstack/react/player/styles/default/layouts/video.css';
|
||||||
|
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
@@ -41,22 +45,6 @@ input::-ms-clear {
|
|||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.player {
|
|
||||||
--brand-color: #f5f5f5;
|
|
||||||
--focus-color: #4e9cf6;
|
|
||||||
--audio-brand: var(--brand-color);
|
|
||||||
--audio-focus-ring-color: var(--focus-color);
|
|
||||||
--audio-border-radius: 2px;
|
|
||||||
--video-brand: var(--brand-color);
|
|
||||||
--video-focus-ring-color: var(--focus-color);
|
|
||||||
--video-border-radius: 8px;
|
|
||||||
@apply w-full;
|
|
||||||
}
|
|
||||||
|
|
||||||
.player[data-view-type='video'] {
|
|
||||||
@apply aspect-video;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ProseMirror p.is-empty::before {
|
.ProseMirror p.is-empty::before {
|
||||||
@apply text-neutral-600 dark:text-neutral-400 float-left h-0 pointer-events-none content-[attr(data-placeholder)];
|
@apply text-neutral-600 dark:text-neutral-400 float-left h-0 pointer-events-none content-[attr(data-placeholder)];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ export default function App() {
|
|||||||
router={router}
|
router={router}
|
||||||
fallbackElement={
|
fallbackElement={
|
||||||
<div className="flex h-full w-full items-center justify-center">
|
<div className="flex h-full w-full items-center justify-center">
|
||||||
<LoaderIcon className="h-6 w-6 animate-spin text-white" />
|
<LoaderIcon className="h-6 w-6 animate-spin" />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
future={{ v7_startTransition: true }}
|
future={{ v7_startTransition: true }}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import NDK, { NDKNip46Signer, NDKPrivateKeySigner } from '@nostr-dev-kit/ndk';
|
import NDK, { NDKNip46Signer, NDKPrivateKeySigner } from '@nostr-dev-kit/ndk';
|
||||||
import { readText } from '@tauri-apps/plugin-clipboard-manager';
|
import { readText } from '@tauri-apps/plugin-clipboard-manager';
|
||||||
|
import { open } from '@tauri-apps/plugin-shell';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@@ -49,6 +50,9 @@ export function ImportAccountScreen() {
|
|||||||
await db.createSetting('nsecbunker', '1');
|
await db.createSetting('nsecbunker', '1');
|
||||||
await db.secureSave(`${pubkey}-nsecbunker`, localSigner.privateKey);
|
await db.secureSave(`${pubkey}-nsecbunker`, localSigner.privateKey);
|
||||||
|
|
||||||
|
// open nsecbunker web app in default browser
|
||||||
|
await open('https://app.nsecbunker.com/keys');
|
||||||
|
|
||||||
const bunker = new NDK({
|
const bunker = new NDK({
|
||||||
explicitRelayUrls: ['wss://relay.nsecbunker.com', 'wss://nostr.vulpem.com'],
|
explicitRelayUrls: ['wss://relay.nsecbunker.com', 'wss://nostr.vulpem.com'],
|
||||||
});
|
});
|
||||||
@@ -141,6 +145,7 @@ export function ImportAccountScreen() {
|
|||||||
</label>
|
</label>
|
||||||
<div className="flex w-full flex-col gap-2">
|
<div className="flex w-full flex-col gap-2">
|
||||||
<input
|
<input
|
||||||
|
readOnly={!!pubkey}
|
||||||
name="npub"
|
name="npub"
|
||||||
type="text"
|
type="text"
|
||||||
value={npub}
|
value={npub}
|
||||||
@@ -170,6 +175,12 @@ export function ImportAccountScreen() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
{npub.indexOf('#') > -1 ? (
|
||||||
|
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
||||||
|
You're using nsecbunker token, keep in mind it only can redeem
|
||||||
|
one-time, you need to login again in the next launch
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import { useProfile } from '@utils/hooks/useProfile';
|
|||||||
import { displayNpub } from '@utils/shortenKey';
|
import { displayNpub } from '@utils/shortenKey';
|
||||||
|
|
||||||
export const ChatListItem = memo(function ChatListItem({ event }: { event: NDKEvent }) {
|
export const ChatListItem = memo(function ChatListItem({ event }: { event: NDKEvent }) {
|
||||||
const { status, user } = useProfile(event.pubkey);
|
const { isLoading, user } = useProfile(event.pubkey);
|
||||||
const decryptedContent = useDecryptMessage(event);
|
const decryptedContent = useDecryptMessage(event);
|
||||||
|
|
||||||
const createdAt = formatCreatedAt(event.created_at, true);
|
const createdAt = formatCreatedAt(event.created_at, true);
|
||||||
const svgURI =
|
const svgURI =
|
||||||
'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(event.pubkey, 90, 50));
|
'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(event.pubkey, 90, 50));
|
||||||
|
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2.5 rounded-md px-3">
|
<div className="flex items-center gap-2.5 rounded-md px-3">
|
||||||
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-400 dark:bg-neutral-600" />
|
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-400 dark:bg-neutral-600" />
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { memo } from 'react';
|
|||||||
import { useProfile } from '@utils/hooks/useProfile';
|
import { useProfile } from '@utils/hooks/useProfile';
|
||||||
|
|
||||||
export const GroupTitle = memo(function GroupTitle({ pubkey }: { pubkey: string }) {
|
export const GroupTitle = memo(function GroupTitle({ pubkey }: { pubkey: string }) {
|
||||||
const { status, user } = useProfile(pubkey);
|
const { isLoading, user } = useProfile(pubkey);
|
||||||
|
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return <div className="h-3 w-24 animate-pulse rounded bg-white/10" />;
|
return <div className="h-3 w-24 animate-pulse rounded bg-white/10" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const UserWithDrawer = memo(function UserWithDrawer({
|
|||||||
}) {
|
}) {
|
||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { status, user } = useProfile(pubkey);
|
const { isLoading, user } = useProfile(pubkey);
|
||||||
|
|
||||||
const [followed, setFollowed] = useState(false);
|
const [followed, setFollowed] = useState(false);
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ export const UserWithDrawer = memo(function UserWithDrawer({
|
|||||||
<Dialog.Portal>
|
<Dialog.Portal>
|
||||||
<Dialog.Content className="fixed right-0 top-0 z-50 flex h-full w-[400px] animate-slideRightAndFade items-center justify-center px-4 pb-4 pt-16 transition-all">
|
<Dialog.Content className="fixed right-0 top-0 z-50 flex h-full w-[400px] animate-slideRightAndFade items-center justify-center px-4 pb-4 pt-16 transition-all">
|
||||||
<div className="h-full w-full overflow-y-auto rounded-lg border border-neutral-300 bg-neutral-200 py-3 dark:border-neutral-700 dark:bg-neutral-800">
|
<div className="h-full w-full overflow-y-auto rounded-lg border border-neutral-300 bg-neutral-200 py-3 dark:border-neutral-700 dark:bg-neutral-800">
|
||||||
{status === 'pending' ? (
|
{isLoading ? (
|
||||||
<div>
|
<div>
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
|
import * as Avatar from '@radix-ui/react-avatar';
|
||||||
|
import { minidenticon } from 'minidenticons';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { useProfile } from '@utils/hooks/useProfile';
|
import { useProfile } from '@utils/hooks/useProfile';
|
||||||
import { displayNpub } from '@utils/shortenKey';
|
import { displayNpub } from '@utils/shortenKey';
|
||||||
|
|
||||||
export function MentionPopupItem({ pubkey, embed }: { pubkey: string; embed?: string }) {
|
export function MentionPopupItem({ pubkey, embed }: { pubkey: string; embed?: string }) {
|
||||||
const { status, user } = useProfile(pubkey, embed);
|
const { isLoading, user } = useProfile(pubkey, embed);
|
||||||
|
const svgURI = useMemo(
|
||||||
|
() => 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(pubkey, 90, 50)),
|
||||||
|
[pubkey]
|
||||||
|
);
|
||||||
|
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2.5 px-2">
|
<div className="flex items-center gap-2.5 px-2">
|
||||||
<div className="relative h-8 w-8 shrink-0 animate-pulse rounded bg-neutral-400 dark:bg-neutral-600" />
|
<div className="relative h-8 w-8 shrink-0 animate-pulse rounded bg-neutral-400 dark:bg-neutral-600" />
|
||||||
@@ -18,14 +26,25 @@ export function MentionPopupItem({ pubkey, embed }: { pubkey: string; embed?: st
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-11 items-center justify-start gap-2.5 px-2 hover:bg-neutral-200 dark:bg-neutral-800">
|
<div className="flex h-11 items-center justify-start gap-2.5 px-2 hover:bg-neutral-200 dark:bg-neutral-800">
|
||||||
<img
|
<Avatar.Root className="shirnk-0 h-8 w-8">
|
||||||
src={user.picture || user.image}
|
<Avatar.Image
|
||||||
alt={pubkey}
|
src={user?.picture || user?.image}
|
||||||
className="shirnk-0 h-8 w-8 rounded-md object-cover"
|
alt={pubkey}
|
||||||
/>
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
className="h-8 w-8 rounded-md object-cover"
|
||||||
|
/>
|
||||||
|
<Avatar.Fallback delayMs={300}>
|
||||||
|
<img
|
||||||
|
src={svgURI}
|
||||||
|
alt={pubkey}
|
||||||
|
className="h-8 w-8 rounded-md bg-black dark:bg-white"
|
||||||
|
/>
|
||||||
|
</Avatar.Fallback>
|
||||||
|
</Avatar.Root>
|
||||||
<div className="flex flex-col items-start gap-px">
|
<div className="flex flex-col items-start gap-px">
|
||||||
<h5 className="max-w-[10rem] truncate text-sm font-medium leading-none text-neutral-900 dark:text-neutral-100">
|
<h5 className="max-w-[10rem] truncate text-sm font-medium leading-none text-neutral-900 dark:text-neutral-100">
|
||||||
{user.display_name || user.displayName || user.name}
|
{user?.display_name || user?.displayName || user?.name}
|
||||||
</h5>
|
</h5>
|
||||||
<span className="text-sm leading-none text-neutral-600 dark:text-neutral-400">
|
<span className="text-sm leading-none text-neutral-600 dark:text-neutral-400">
|
||||||
{displayNpub(pubkey, 16)}
|
{displayNpub(pubkey, 16)}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { nip19 } from 'nostr-tools';
|
|||||||
import { EventPointer } from 'nostr-tools/lib/types/nip19';
|
import { EventPointer } from 'nostr-tools/lib/types/nip19';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
import { ArrowLeftIcon, CheckCircleIcon, ShareIcon } from '@shared/icons';
|
import { ArrowLeftIcon, CheckCircleIcon, ShareIcon } from '@shared/icons';
|
||||||
import { NoteReplyForm } from '@shared/notes';
|
import { NoteReplyForm } from '@shared/notes';
|
||||||
@@ -40,14 +41,18 @@ export function ArticleNoteScreen() {
|
|||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
const share = async () => {
|
const share = async () => {
|
||||||
await writeText(
|
try {
|
||||||
'https://njump.me/' +
|
await writeText(
|
||||||
nip19.neventEncode({ id: data.id, author: data.pubkey } as EventPointer)
|
'https://njump.me/' +
|
||||||
);
|
nip19.neventEncode({ id: data?.id, author: data?.pubkey } as EventPointer)
|
||||||
// update state
|
);
|
||||||
setIsCopy(true);
|
// update state
|
||||||
// reset state after 2 sec
|
setIsCopy(true);
|
||||||
setTimeout(() => setIsCopy(false), 2000);
|
// reset state after 2 sec
|
||||||
|
setTimeout(() => setIsCopy(false), 2000);
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { nip19 } from 'nostr-tools';
|
|||||||
import { EventPointer } from 'nostr-tools/lib/types/nip19';
|
import { EventPointer } from 'nostr-tools/lib/types/nip19';
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
import { ArrowLeftIcon, CheckCircleIcon, ReplyIcon, ShareIcon } from '@shared/icons';
|
import { ArrowLeftIcon, CheckCircleIcon, ReplyIcon, ShareIcon } from '@shared/icons';
|
||||||
import {
|
import {
|
||||||
@@ -30,14 +31,18 @@ export function TextNoteScreen() {
|
|||||||
const [isCopy, setIsCopy] = useState(false);
|
const [isCopy, setIsCopy] = useState(false);
|
||||||
|
|
||||||
const share = async () => {
|
const share = async () => {
|
||||||
await writeText(
|
try {
|
||||||
'https://njump.me/' +
|
await writeText(
|
||||||
nip19.neventEncode({ id: data.id, author: data.pubkey } as EventPointer)
|
'https://njump.me/' +
|
||||||
);
|
nip19.neventEncode({ id: data?.id, author: data?.pubkey } as EventPointer)
|
||||||
// update state
|
);
|
||||||
setIsCopy(true);
|
// update state
|
||||||
// reset state after 2 sec
|
setIsCopy(true);
|
||||||
setTimeout(() => setIsCopy(false), 2000);
|
// reset state after 2 sec
|
||||||
|
setTimeout(() => setIsCopy(false), 2000);
|
||||||
|
} catch (e) {
|
||||||
|
toast.error(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollToReply = () => {
|
const scrollToReply = () => {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
|
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
|
import { normalizeRelayUrl } from 'nostr-fetch';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { VList } from 'virtua';
|
import { VList } from 'virtua';
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ export function RelayEventList({ relayUrl }: { relayUrl: string }) {
|
|||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const url = 'wss://' + relayUrl;
|
const url = 'wss://' + relayUrl;
|
||||||
const events = await fetcher.fetchLatestEvents(
|
const events = await fetcher.fetchLatestEvents(
|
||||||
[url],
|
[normalizeRelayUrl(url)],
|
||||||
{
|
{
|
||||||
kinds: [NDKKind.Text, NDKKind.Repost],
|
kinds: [NDKKind.Text, NDKKind.Repost],
|
||||||
},
|
},
|
||||||
@@ -24,6 +25,8 @@ export function RelayEventList({ relayUrl }: { relayUrl: string }) {
|
|||||||
return events as unknown as NDKEvent[];
|
return events as unknown as NDKEvent[];
|
||||||
},
|
},
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
|
refetchOnReconnect: false,
|
||||||
|
refetchOnMount: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderItem = useCallback(
|
const renderItem = useCallback(
|
||||||
@@ -41,19 +44,18 @@ export function RelayEventList({ relayUrl }: { relayUrl: string }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full">
|
<VList className="mx-auto h-full w-full max-w-[500px] pt-10 scrollbar-none">
|
||||||
<VList className="mx-auto w-full max-w-[500px] scrollbar-none">
|
{status === 'pending' ? (
|
||||||
{status === 'pending' ? (
|
<div className="flex h-full w-full items-center justify-center">
|
||||||
<div className="flex h-full w-full items-center justify-center">
|
<div className="inline-flex flex-col items-center justify-center gap-2">
|
||||||
<div className="inline-flex flex-col items-center justify-center gap-2">
|
<LoaderIcon className="h-5 w-5 animate-spin text-white" />
|
||||||
<LoaderIcon className="h-5 w-5 animate-spin text-white" />
|
<p className="text-sm font-medium text-white/80">Loading newsfeed...</p>
|
||||||
<p className="text-sm font-medium text-white/80">Loading newsfeed...</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
</div>
|
||||||
data.map((item) => renderItem(item))
|
) : (
|
||||||
)}
|
data.map((item) => renderItem(item))
|
||||||
</VList>
|
)}
|
||||||
</div>
|
<div className="h-20" />
|
||||||
|
</VList>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import { useNostr } from '@utils/hooks/useNostr';
|
|||||||
import { useRelay } from '@utils/hooks/useRelay';
|
import { useRelay } from '@utils/hooks/useRelay';
|
||||||
|
|
||||||
export function RelayList() {
|
export function RelayList() {
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const { getAllRelaysByUsers } = useNostr();
|
const { getAllRelaysByUsers } = useNostr();
|
||||||
const { connectRelay } = useRelay();
|
const { connectRelay } = useRelay();
|
||||||
const { status, data } = useQuery({
|
const { status, data } = useQuery({
|
||||||
@@ -24,6 +22,8 @@ export function RelayList() {
|
|||||||
staleTime: Infinity,
|
staleTime: Infinity,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const inspectRelay = (relayUrl: string) => {
|
const inspectRelay = (relayUrl: string) => {
|
||||||
const url = new URL(relayUrl);
|
const url = new URL(relayUrl);
|
||||||
navigate(`/relays/${url.hostname}`);
|
navigate(`/relays/${url.hostname}`);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { RelayForm } from '@app/relays/components/relayForm';
|
|||||||
import { useNDK } from '@libs/ndk/provider';
|
import { useNDK } from '@libs/ndk/provider';
|
||||||
import { useStorage } from '@libs/storage/provider';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { CancelIcon } from '@shared/icons';
|
import { CancelIcon, RefreshIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { useRelay } from '@utils/hooks/useRelay';
|
import { useRelay } from '@utils/hooks/useRelay';
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ export function UserRelayList() {
|
|||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { removeRelay } = useRelay();
|
const { removeRelay } = useRelay();
|
||||||
const { status, data } = useQuery({
|
const { status, data, refetch } = useQuery({
|
||||||
queryKey: ['relays', db.account.pubkey],
|
queryKey: ['relays', db.account.pubkey],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const event = await ndk.fetchEvent(
|
const event = await ndk.fetchEvent(
|
||||||
@@ -25,7 +25,7 @@ export function UserRelayList() {
|
|||||||
{ cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY }
|
{ cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!event) throw new Error('relay set not found');
|
if (!event) return [];
|
||||||
return event.tags;
|
return event.tags;
|
||||||
},
|
},
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
@@ -35,15 +35,22 @@ export function UserRelayList() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="col-span-1">
|
<div className="col-span-1">
|
||||||
<div className="inline-flex h-16 w-full items-center border-b border-neutral-100 px-3 dark:border-neutral-900">
|
<div className="inline-flex h-16 w-full items-center justify-between border-b border-neutral-100 px-3 dark:border-neutral-900">
|
||||||
<h3 className="font-semibold">Connected relays</h3>
|
<h3 className="font-semibold">Connected relays</h3>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => refetch()}
|
||||||
|
className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md hover:bg-neutral-100 dark:hover:bg-neutral-900"
|
||||||
|
>
|
||||||
|
<RefreshIcon className="h-4 w-4" />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3 flex flex-col gap-2 px-3">
|
<div className="mt-3 flex flex-col gap-2 px-3">
|
||||||
{status === 'pending' ? (
|
{status === 'pending' ? (
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
) : !data ? (
|
) : !data.length ? (
|
||||||
<div className="flex h-20 w-full items-center justify-center rounded-xl bg-neutral-100 dark:bg-neutral-900">
|
<div className="flex h-20 w-full items-center justify-center rounded-xl bg-neutral-50 dark:bg-neutral-950">
|
||||||
<p className="text-sm font-medium">You not have personal relay set yet</p>
|
<p className="text-sm font-medium">You not have personal relay list yet</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
data.map((item) => (
|
data.map((item) => (
|
||||||
@@ -68,8 +75,8 @@ export function UserRelayList() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="inline-flex items-center gap-2">
|
<div className="inline-flex items-center gap-2">
|
||||||
{item[2] ? (
|
{item[2]?.length ? (
|
||||||
<div className="inline-flex h-6 w-max items-center justify-center rounded bg-neutral-200 px-2 text-xs font-medium capitalize dark:bg-neutral-900">
|
<div className="inline-flex h-6 w-max items-center justify-center rounded bg-neutral-200 px-2 text-xs font-medium capitalize dark:bg-neutral-800">
|
||||||
{item[2]}
|
{item[2]}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { displayNpub } from '@utils/shortenKey';
|
|||||||
|
|
||||||
export function ProfileCard() {
|
export function ProfileCard() {
|
||||||
const { db } = useStorage();
|
const { db } = useStorage();
|
||||||
const { status, user } = useProfile(db.account.pubkey);
|
const { isLoading, user } = useProfile(db.account.pubkey);
|
||||||
|
|
||||||
const svgURI =
|
const svgURI =
|
||||||
'data:image/svg+xml;utf8,' +
|
'data:image/svg+xml;utf8,' +
|
||||||
@@ -19,7 +19,7 @@ export function ProfileCard() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-4 h-56 w-full rounded-2xl bg-neutral-100 transition-all duration-150 ease-smooth hover:scale-105 dark:bg-neutral-900">
|
<div className="mb-4 h-56 w-full rounded-2xl bg-neutral-100 transition-all duration-150 ease-smooth hover:scale-105 dark:bg-neutral-900">
|
||||||
{status === 'pending' ? (
|
{isLoading ? (
|
||||||
<div className="flex h-full w-full items-center justify-center">
|
<div className="flex h-full w-full items-center justify-center">
|
||||||
<LoaderIcon className="h-4 w-4 animate-spin" />
|
<LoaderIcon className="h-4 w-4 animate-spin" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export function UserProfile({ pubkey }: { pubkey: string }) {
|
|||||||
<div className="flex flex-col items-center gap-1">
|
<div className="flex flex-col items-center gap-1">
|
||||||
<div className="inline-flex flex-col items-center">
|
<div className="inline-flex flex-col items-center">
|
||||||
<h5 className="text-center text-xl font-semibold text-neutral-900 dark:text-neutral-100">
|
<h5 className="text-center text-xl font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
{user.name || user.display_name || user.displayName || 'No name'}
|
{user?.name || user?.display_name || user?.displayName || 'No name'}
|
||||||
</h5>
|
</h5>
|
||||||
{user?.nip05 ? (
|
{user?.nip05 ? (
|
||||||
<NIP05
|
<NIP05
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { ask } from '@tauri-apps/plugin-dialog';
|
|||||||
import { relaunch } from '@tauri-apps/plugin-process';
|
import { relaunch } from '@tauri-apps/plugin-process';
|
||||||
import { NostrFetcher, normalizeRelayUrlSet } from 'nostr-fetch';
|
import { NostrFetcher, normalizeRelayUrlSet } from 'nostr-fetch';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
import NDKCacheAdapterTauri from '@libs/ndk/cache';
|
import NDKCacheAdapterTauri from '@libs/ndk/cache';
|
||||||
import { useStorage } from '@libs/storage/provider';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
@@ -27,51 +28,73 @@ export const NDKInstance = () => {
|
|||||||
async function getSigner(nsecbunker?: boolean) {
|
async function getSigner(nsecbunker?: boolean) {
|
||||||
if (!db.account) return;
|
if (!db.account) return;
|
||||||
|
|
||||||
// NIP-46 Signer
|
try {
|
||||||
if (nsecbunker) {
|
// NIP-46 Signer
|
||||||
const localSignerPrivkey = await db.secureLoad(`${db.account.pubkey}-nsecbunker`);
|
if (nsecbunker) {
|
||||||
if (!localSignerPrivkey) return null;
|
const localSignerPrivkey = await db.secureLoad(`${db.account.pubkey}-nsecbunker`);
|
||||||
|
if (!localSignerPrivkey) return null;
|
||||||
|
|
||||||
const localSigner = new NDKPrivateKeySigner(localSignerPrivkey);
|
const localSigner = new NDKPrivateKeySigner(localSignerPrivkey);
|
||||||
const bunker = new NDK({
|
const bunker = new NDK({
|
||||||
explicitRelayUrls: ['wss://relay.nsecbunker.com', 'wss://nostr.vulpem.com'],
|
explicitRelayUrls: ['wss://relay.nsecbunker.com', 'wss://nostr.vulpem.com'],
|
||||||
});
|
});
|
||||||
bunker.connect();
|
bunker.connect();
|
||||||
|
|
||||||
const remoteSigner = new NDKNip46Signer(bunker, db.account.id, localSigner);
|
const remoteSigner = new NDKNip46Signer(bunker, db.account.id, localSigner);
|
||||||
await remoteSigner.blockUntilReady();
|
await remoteSigner.blockUntilReady();
|
||||||
|
|
||||||
return remoteSigner;
|
return remoteSigner;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Privkey Signer
|
||||||
|
const userPrivkey = await db.secureLoad(db.account.pubkey);
|
||||||
|
if (!userPrivkey) return null;
|
||||||
|
return new NDKPrivateKeySigner(userPrivkey);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
if (e === 'Token already redeemed') {
|
||||||
|
toast.info(
|
||||||
|
'nsecbunker token already redeemed. You need to re-login with another token.'
|
||||||
|
);
|
||||||
|
|
||||||
|
await db.secureRemove(`${db.account.pubkey}-nsecbunker`);
|
||||||
|
await db.accountLogout();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Privkey Signer
|
|
||||||
const userPrivkey = await db.secureLoad(db.account.pubkey);
|
|
||||||
if (!userPrivkey) return null;
|
|
||||||
return new NDKPrivateKeySigner(userPrivkey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initNDK() {
|
async function initNDK() {
|
||||||
|
const outboxSetting = await db.getSettingValue('outbox');
|
||||||
|
const bunkerSetting = await db.getSettingValue('nsecbunker');
|
||||||
|
|
||||||
|
const bunker = !!parseInt(bunkerSetting);
|
||||||
|
const outbox = !!parseInt(outboxSetting);
|
||||||
|
|
||||||
|
const explicitRelayUrls = normalizeRelayUrlSet([
|
||||||
|
'wss://relay.damus.io',
|
||||||
|
'wss://relay.nostr.band',
|
||||||
|
'wss://nos.lol',
|
||||||
|
'wss://nostr.mutinywallet.com',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// #TODO: user should config outbox relays
|
||||||
|
const outboxRelayUrls = normalizeRelayUrlSet(['wss://purplepag.es']);
|
||||||
|
|
||||||
|
// #TODO: user should config blacklist relays
|
||||||
|
const blacklistRelayUrls = normalizeRelayUrlSet(['wss://brb.io']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const outboxSetting = await db.getSettingValue('outbox');
|
|
||||||
const bunkerSetting = await db.getSettingValue('nsecbunker');
|
|
||||||
const explicitRelayUrls = normalizeRelayUrlSet([
|
|
||||||
'wss://relay.damus.io',
|
|
||||||
'wss://relay.nostr.band',
|
|
||||||
'wss://nos.lol',
|
|
||||||
'wss://nostr.mutinywallet.com',
|
|
||||||
]);
|
|
||||||
|
|
||||||
const bunker = !!parseInt(bunkerSetting);
|
|
||||||
const outbox = !!parseInt(outboxSetting);
|
|
||||||
|
|
||||||
const tauriAdapter = new NDKCacheAdapterTauri(db);
|
const tauriAdapter = new NDKCacheAdapterTauri(db);
|
||||||
const instance = new NDK({
|
const instance = new NDK({
|
||||||
explicitRelayUrls,
|
explicitRelayUrls,
|
||||||
cacheAdapter: tauriAdapter,
|
outboxRelayUrls,
|
||||||
outboxRelayUrls: ['wss://purplepag.es'],
|
blacklistRelayUrls,
|
||||||
enableOutboxModel: outbox,
|
enableOutboxModel: outbox,
|
||||||
autoConnectUserRelays: true,
|
autoConnectUserRelays: true,
|
||||||
autoFetchUserMutelist: true,
|
autoFetchUserMutelist: true,
|
||||||
|
cacheAdapter: tauriAdapter,
|
||||||
// clientName: 'Lume',
|
// clientName: 'Lume',
|
||||||
// clientNip89: '',
|
// clientNip89: '',
|
||||||
});
|
});
|
||||||
@@ -88,9 +111,9 @@ export const NDKInstance = () => {
|
|||||||
if (db.account) {
|
if (db.account) {
|
||||||
const user = instance.getUser({ pubkey: db.account.pubkey });
|
const user = instance.getUser({ pubkey: db.account.pubkey });
|
||||||
instance.activeUser = user;
|
instance.activeUser = user;
|
||||||
db.account.contacts = [...(await user.follows(undefined, outbox))].map(
|
|
||||||
(user) => user.pubkey
|
const contacts = await user.follows(undefined /* outbox */);
|
||||||
);
|
db.account.contacts = [...contacts].map((user) => user.pubkey);
|
||||||
|
|
||||||
// prefetch newsfeed
|
// prefetch newsfeed
|
||||||
await queryClient.prefetchInfiniteQuery({
|
await queryClient.prefetchInfiniteQuery({
|
||||||
|
|||||||
@@ -416,7 +416,14 @@ export class LumeStorage {
|
|||||||
return await this.db.execute(`DELETE FROM relays WHERE relay = "${relay}";`);
|
return await this.db.execute(`DELETE FROM relays WHERE relay = "${relay}";`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createSetting(key: string, value: string) {
|
public async createSetting(key: string, value: string | undefined) {
|
||||||
|
if (value) {
|
||||||
|
return await this.db.execute(
|
||||||
|
'INSERT OR IGNORE INTO settings (key, value) VALUES ($1, $2);',
|
||||||
|
[key, value]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const currentSetting = await this.checkSettingValue(key);
|
const currentSetting = await this.checkSettingValue(key);
|
||||||
|
|
||||||
if (!currentSetting)
|
if (!currentSetting)
|
||||||
@@ -470,9 +477,7 @@ export class LumeStorage {
|
|||||||
await this.db.execute("UPDATE accounts SET is_active = '0' WHERE id = $1;", [
|
await this.db.execute("UPDATE accounts SET is_active = '0' WHERE id = $1;", [
|
||||||
this.account.id,
|
this.account.id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.account = null;
|
this.account = null;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async close() {
|
public async close() {
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ import App from './app';
|
|||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
gcTime: 1000 * 60 * 60 * 24, // 24 hours
|
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), // 10 seconds
|
||||||
queries: {
|
|
||||||
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), // 10 seconds
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export function ActiveAccount() {
|
|||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
style={{ contentVisibility: 'auto' }}
|
style={{ contentVisibility: 'auto' }}
|
||||||
className="aspect-square h-auto w-full rounded-md"
|
className="aspect-square h-auto w-full rounded-md object-cover"
|
||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={150}>
|
<Avatar.Fallback delayMs={150}>
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function Logout() {
|
|||||||
|
|
||||||
// remove private key
|
// remove private key
|
||||||
await db.secureRemove(db.account.pubkey);
|
await db.secureRemove(db.account.pubkey);
|
||||||
await db.secureRemove(db.account.pubkey + '-nsecbunker');
|
await db.secureRemove(`${db.account.pubkey}-nsecbunker`);
|
||||||
|
|
||||||
// logout
|
// logout
|
||||||
await db.accountLogout();
|
await db.accountLogout();
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { Logout } from '@shared/accounts/logout';
|
||||||
import { HorizontalDotsIcon } from '@shared/icons';
|
import { HorizontalDotsIcon } from '@shared/icons';
|
||||||
import { Logout } from '@shared/logout';
|
|
||||||
|
|
||||||
export function AccountMoreActions() {
|
export function AccountMoreActions() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -40,7 +40,11 @@ export const NIP05 = memo(function NIP05({
|
|||||||
|
|
||||||
const data: NIP05 = await res.json();
|
const data: NIP05 = await res.json();
|
||||||
if (data.names) {
|
if (data.names) {
|
||||||
if (data.names[localPath] !== pubkey) return false;
|
if (
|
||||||
|
data.names[localPath.toLowerCase()] !== pubkey ||
|
||||||
|
data.names[localPath] !== pubkey
|
||||||
|
)
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -60,17 +64,13 @@ export const NIP05 = memo(function NIP05({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="inline-flex items-center gap-1">
|
<div className="inline-flex items-center gap-1">
|
||||||
<p className={twMerge('text-sm font-medium', className)}>{nip05}</p>
|
<p className={twMerge('text-sm font-medium', className)}>
|
||||||
|
{nip05.startsWith('_@') ? nip05.replace('_@', '') : nip05}
|
||||||
|
</p>
|
||||||
{data === true ? (
|
{data === true ? (
|
||||||
<div className="inline-flex h-5 w-max shrink-0 items-center justify-center gap-1 rounded-full bg-teal-500 pl-0.5 pr-1.5 text-xs font-medium text-white">
|
<VerifiedIcon className="h-4 w-4 text-teal-500" />
|
||||||
<VerifiedIcon className="h-4 w-4" />
|
|
||||||
Verified
|
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
<div className="inline-flex h-5 w-max shrink-0 items-center justify-center gap-1.5 rounded-full bg-red-500 pl-0.5 pr-1.5 text-xs font-medium text-white">
|
<UnverifiedIcon className="h-4 w-4 text-red-500" />
|
||||||
<UnverifiedIcon className="h-4 w-4" />
|
|
||||||
Unverified
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { CancelIcon, ZapIcon } from '@shared/icons';
|
|||||||
import { useProfile } from '@utils/hooks/useProfile';
|
import { useProfile } from '@utils/hooks/useProfile';
|
||||||
import { sendNativeNotification } from '@utils/notification';
|
import { sendNativeNotification } from '@utils/notification';
|
||||||
import { compactNumber } from '@utils/number';
|
import { compactNumber } from '@utils/number';
|
||||||
|
import { displayNpub } from '@utils/shortenKey';
|
||||||
|
|
||||||
export function NoteZap({ event }: { event: NDKEvent }) {
|
export function NoteZap({ event }: { event: NDKEvent }) {
|
||||||
const nwc = useRef(null);
|
const nwc = useRef(null);
|
||||||
@@ -119,7 +120,8 @@ export function NoteZap({ event }: { event: NDKEvent }) {
|
|||||||
<div className="inline-flex w-full shrink-0 items-center justify-between px-5 py-3">
|
<div className="inline-flex w-full shrink-0 items-center justify-between px-5 py-3">
|
||||||
<div className="w-6" />
|
<div className="w-6" />
|
||||||
<Dialog.Title className="text-center font-semibold">
|
<Dialog.Title className="text-center font-semibold">
|
||||||
Send tip to {user?.name || user?.display_name || user?.displayName}
|
Send tip to{' '}
|
||||||
|
{user?.name || user?.displayName || displayNpub(event.pubkey, 16)}
|
||||||
</Dialog.Title>
|
</Dialog.Title>
|
||||||
<Dialog.Close className="inline-flex h-6 w-6 items-center justify-center rounded-md bg-neutral-100 dark:bg-neutral-900">
|
<Dialog.Close className="inline-flex h-6 w-6 items-center justify-center rounded-md bg-neutral-100 dark:bg-neutral-900">
|
||||||
<CancelIcon className="h-4 w-4" />
|
<CancelIcon className="h-4 w-4" />
|
||||||
|
|||||||
@@ -4,12 +4,22 @@ import { User } from '@shared/user';
|
|||||||
import { useEvent } from '@utils/hooks/useEvent';
|
import { useEvent } from '@utils/hooks/useEvent';
|
||||||
|
|
||||||
export function ChildNote({ id, isRoot }: { id: string; isRoot?: boolean }) {
|
export function ChildNote({ id, isRoot }: { id: string; isRoot?: boolean }) {
|
||||||
const { status, data } = useEvent(id);
|
const { isFetching, isError, data } = useEvent(id);
|
||||||
|
|
||||||
if (status === 'pending' || !data) {
|
if (isFetching) {
|
||||||
return <NoteSkeleton />;
|
return <NoteSkeleton />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
return (
|
||||||
|
<div className="relative flex gap-3">
|
||||||
|
<div className="relative flex-1 rounded-md bg-neutral-200 px-2 py-2 dark:bg-neutral-800">
|
||||||
|
Failed to fetch event
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex gap-3">
|
<div className="relative flex gap-3">
|
||||||
<div className="relative flex-1 rounded-md bg-neutral-200 px-2 py-2 dark:bg-neutral-800">
|
<div className="relative flex-1 rounded-md bg-neutral-200 px-2 py-2 dark:bg-neutral-800">
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||||
import { downloadDir } from '@tauri-apps/api/path';
|
import { downloadDir } from '@tauri-apps/api/path';
|
||||||
import { download } from '@tauri-apps/plugin-upload';
|
import { download } from '@tauri-apps/plugin-upload';
|
||||||
|
import { MediaPlayer, MediaProvider } from '@vidstack/react';
|
||||||
import {
|
import {
|
||||||
MediaControlBar,
|
DefaultVideoLayout,
|
||||||
MediaController,
|
defaultLayoutIcons,
|
||||||
MediaFullscreenButton,
|
} from '@vidstack/react/player/layouts/default';
|
||||||
MediaMuteButton,
|
|
||||||
MediaPlayButton,
|
|
||||||
MediaTimeRange,
|
|
||||||
} from 'media-chrome/dist/react';
|
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -32,7 +29,7 @@ export function FileNote({ event }: { event: NDKEvent }) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 'image':
|
case 'image':
|
||||||
return (
|
return (
|
||||||
<div key={url} className="group relative">
|
<div className="group relative">
|
||||||
<img
|
<img
|
||||||
src={url}
|
src={url}
|
||||||
alt={url}
|
alt={url}
|
||||||
@@ -52,18 +49,15 @@ export function FileNote({ event }: { event: NDKEvent }) {
|
|||||||
);
|
);
|
||||||
case 'video':
|
case 'video':
|
||||||
return (
|
return (
|
||||||
<MediaController
|
<MediaPlayer
|
||||||
key={url}
|
src={url}
|
||||||
className="aspect-video w-full overflow-hidden rounded-lg"
|
className="w-full overflow-hidden rounded-lg"
|
||||||
|
aspectRatio="16/9"
|
||||||
|
load="visible"
|
||||||
>
|
>
|
||||||
<video slot="media" src={url} preload="metadata" muted />
|
<MediaProvider />
|
||||||
<MediaControlBar>
|
<DefaultVideoLayout icons={defaultLayoutIcons} />
|
||||||
<MediaPlayButton></MediaPlayButton>
|
</MediaPlayer>
|
||||||
<MediaTimeRange></MediaTimeRange>
|
|
||||||
<MediaMuteButton></MediaMuteButton>
|
|
||||||
<MediaFullscreenButton></MediaFullscreenButton>
|
|
||||||
</MediaControlBar>
|
|
||||||
</MediaController>
|
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import { NDKTag } from '@nostr-dev-kit/ndk';
|
import { NDKTag } from '@nostr-dev-kit/ndk';
|
||||||
import { downloadDir } from '@tauri-apps/api/path';
|
import { downloadDir } from '@tauri-apps/api/path';
|
||||||
import { download } from '@tauri-apps/plugin-upload';
|
import { download } from '@tauri-apps/plugin-upload';
|
||||||
|
import { MediaPlayer, MediaProvider } from '@vidstack/react';
|
||||||
import {
|
import {
|
||||||
MediaControlBar,
|
DefaultVideoLayout,
|
||||||
MediaController,
|
defaultLayoutIcons,
|
||||||
MediaFullscreenButton,
|
} from '@vidstack/react/player/layouts/default';
|
||||||
MediaMuteButton,
|
|
||||||
MediaPlayButton,
|
|
||||||
MediaTimeRange,
|
|
||||||
} from 'media-chrome/dist/react';
|
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -50,18 +47,15 @@ export function FileKind({ tags }: { tags: NDKTag[] }) {
|
|||||||
|
|
||||||
if (type === 'video') {
|
if (type === 'video') {
|
||||||
return (
|
return (
|
||||||
<MediaController
|
<MediaPlayer
|
||||||
key={url}
|
src={url}
|
||||||
className="aspect-video w-full overflow-hidden rounded-lg"
|
className="w-full overflow-hidden rounded-lg"
|
||||||
|
aspectRatio="16/9"
|
||||||
|
load="visible"
|
||||||
>
|
>
|
||||||
<video slot="media" src={url} preload="metadata" muted />
|
<MediaProvider />
|
||||||
<MediaControlBar>
|
<DefaultVideoLayout icons={defaultLayoutIcons} />
|
||||||
<MediaPlayButton></MediaPlayButton>
|
</MediaPlayer>
|
||||||
<MediaTimeRange></MediaTimeRange>
|
|
||||||
<MediaMuteButton></MediaMuteButton>
|
|
||||||
<MediaFullscreenButton></MediaFullscreenButton>
|
|
||||||
</MediaControlBar>
|
|
||||||
</MediaController>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const MentionNote = memo(function MentionNote({
|
|||||||
id: string;
|
id: string;
|
||||||
editing?: boolean;
|
editing?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { status, data } = useEvent(id);
|
const { isFetching, isError, data } = useEvent(id);
|
||||||
const { addWidget } = useWidget();
|
const { addWidget } = useWidget();
|
||||||
|
|
||||||
const renderKind = (event: NDKEvent) => {
|
const renderKind = (event: NDKEvent) => {
|
||||||
@@ -36,7 +36,7 @@ export const MentionNote = memo(function MentionNote({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (status === 'pending') {
|
if (isFetching) {
|
||||||
return (
|
return (
|
||||||
<div className="w-full cursor-default rounded-lg bg-neutral-100 p-3 dark:bg-neutral-900">
|
<div className="w-full cursor-default rounded-lg bg-neutral-100 p-3 dark:bg-neutral-900">
|
||||||
<NoteSkeleton />
|
<NoteSkeleton />
|
||||||
@@ -44,6 +44,14 @@ export const MentionNote = memo(function MentionNote({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
return (
|
||||||
|
<div className="w-full cursor-default rounded-lg bg-neutral-100 p-3 dark:bg-neutral-900">
|
||||||
|
Failed to fetch event
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="my-2 flex w-full cursor-default flex-col gap-1 rounded-lg bg-neutral-100 dark:bg-neutral-900">
|
<div className="my-2 flex w-full cursor-default flex-col gap-1 rounded-lg bg-neutral-100 dark:bg-neutral-900">
|
||||||
<div className="mt-3 px-3">
|
<div className="mt-3 px-3">
|
||||||
|
|||||||
@@ -20,12 +20,7 @@ export const MentionUser = memo(function MentionUser({ pubkey }: { pubkey: strin
|
|||||||
}
|
}
|
||||||
className="break-words text-blue-500 hover:text-blue-600"
|
className="break-words text-blue-500 hover:text-blue-600"
|
||||||
>
|
>
|
||||||
{'@' +
|
{'@' + (user?.name || user?.displayName || user?.username || 'unknown')}
|
||||||
(user?.name ||
|
|
||||||
user?.display_name ||
|
|
||||||
user?.displayName ||
|
|
||||||
user?.username ||
|
|
||||||
'unknown')}
|
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,27 +1,19 @@
|
|||||||
|
import { MediaPlayer, MediaProvider } from '@vidstack/react';
|
||||||
import {
|
import {
|
||||||
MediaControlBar,
|
DefaultVideoLayout,
|
||||||
MediaController,
|
defaultLayoutIcons,
|
||||||
MediaFullscreenButton,
|
} from '@vidstack/react/player/layouts/default';
|
||||||
MediaLoadingIndicator,
|
|
||||||
MediaMuteButton,
|
|
||||||
MediaPlayButton,
|
|
||||||
MediaTimeRange,
|
|
||||||
} from 'media-chrome/dist/react';
|
|
||||||
|
|
||||||
export function VideoPreview({ url }: { url: string }) {
|
export function VideoPreview({ url }: { url: string }) {
|
||||||
return (
|
return (
|
||||||
<MediaController
|
<MediaPlayer
|
||||||
key={url}
|
src={url}
|
||||||
className="my-2 aspect-video w-full overflow-hidden rounded-lg"
|
className="my-2 w-full overflow-hidden rounded-lg"
|
||||||
|
aspectRatio="16/9"
|
||||||
|
load="visible"
|
||||||
>
|
>
|
||||||
<video slot="media" src={url} preload="metadata" muted />
|
<MediaProvider />
|
||||||
<MediaLoadingIndicator slot="centered-chrome"></MediaLoadingIndicator>
|
<DefaultVideoLayout icons={defaultLayoutIcons} />
|
||||||
<MediaControlBar>
|
</MediaPlayer>
|
||||||
<MediaPlayButton></MediaPlayButton>
|
|
||||||
<MediaTimeRange></MediaTimeRange>
|
|
||||||
<MediaMuteButton></MediaMuteButton>
|
|
||||||
<MediaFullscreenButton></MediaFullscreenButton>
|
|
||||||
</MediaControlBar>
|
|
||||||
</MediaController>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,20 +40,33 @@ export const User = memo(function User({
|
|||||||
embedProfile?: string;
|
embedProfile?: string;
|
||||||
subtext?: string;
|
subtext?: string;
|
||||||
}) {
|
}) {
|
||||||
const { status, user } = useProfile(pubkey, embedProfile);
|
const { isLoading, user } = useProfile(pubkey, embedProfile);
|
||||||
|
|
||||||
const createdAt = useMemo(() => formatCreatedAt(time, variant === 'chat'), [pubkey]);
|
const createdAt = useMemo(() => formatCreatedAt(time, variant === 'chat'), [time]);
|
||||||
const svgURI = useMemo(
|
const fallbackName = useMemo(() => displayNpub(pubkey, 16), [pubkey]);
|
||||||
|
const fallbackAvatar = useMemo(
|
||||||
() => 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(pubkey, 90, 50)),
|
() => 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(pubkey, 90, 50)),
|
||||||
[pubkey]
|
[pubkey]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (variant === 'mention') {
|
if (variant === 'mention') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="h-6 w-6 shrink-0 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<Avatar.Root className="shrink-0">
|
||||||
<div className="h-3.5 w-36 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<Avatar.Image
|
||||||
|
src={fallbackAvatar}
|
||||||
|
alt={pubkey}
|
||||||
|
className="h-6 w-6 rounded-md bg-black dark:bg-white"
|
||||||
|
/>
|
||||||
|
</Avatar.Root>
|
||||||
|
<div className="flex flex-1 items-baseline gap-2">
|
||||||
|
<h5 className="max-w-[10rem] truncate font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
|
{fallbackName}
|
||||||
|
</h5>
|
||||||
|
<span className="text-neutral-600 dark:text-neutral-400">·</span>
|
||||||
|
<span className="text-neutral-600 dark:text-neutral-400">{createdAt}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -70,7 +83,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-6 w-6 rounded-md bg-black dark:bg-white"
|
className="h-6 w-6 rounded-md bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -78,10 +91,7 @@ export const User = memo(function User({
|
|||||||
</Avatar.Root>
|
</Avatar.Root>
|
||||||
<div className="flex flex-1 items-baseline gap-2">
|
<div className="flex flex-1 items-baseline gap-2">
|
||||||
<h5 className="max-w-[10rem] truncate font-semibold text-neutral-900 dark:text-neutral-100">
|
<h5 className="max-w-[10rem] truncate font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
{user?.name ||
|
{user?.name || user?.display_name || user?.displayName || fallbackName}
|
||||||
user?.display_name ||
|
|
||||||
user?.displayName ||
|
|
||||||
displayNpub(pubkey, 16)}
|
|
||||||
</h5>
|
</h5>
|
||||||
<span className="text-neutral-600 dark:text-neutral-400">·</span>
|
<span className="text-neutral-600 dark:text-neutral-400">·</span>
|
||||||
<span className="text-neutral-600 dark:text-neutral-400">{createdAt}</span>
|
<span className="text-neutral-600 dark:text-neutral-400">{createdAt}</span>
|
||||||
@@ -91,11 +101,19 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'notify') {
|
if (variant === 'notify') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="h-8 w-8 shrink-0 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<Avatar.Root className="h-8 w-8 shrink-0">
|
||||||
<div className="h-3.5 w-36 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<Avatar.Image
|
||||||
|
src={fallbackAvatar}
|
||||||
|
alt={pubkey}
|
||||||
|
className="h-8 w-8 rounded-md bg-black dark:bg-white"
|
||||||
|
/>
|
||||||
|
</Avatar.Root>
|
||||||
|
<h5 className="max-w-[10rem] truncate font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
|
{fallbackName}
|
||||||
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -112,24 +130,21 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-8 w-8 rounded-md bg-black dark:bg-white"
|
className="h-8 w-8 rounded-md bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
</Avatar.Fallback>
|
</Avatar.Fallback>
|
||||||
</Avatar.Root>
|
</Avatar.Root>
|
||||||
<h5 className="max-w-[10rem] truncate font-semibold text-neutral-900 dark:text-neutral-100">
|
<h5 className="max-w-[10rem] truncate font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
{user?.name ||
|
{user?.name || user?.display_name || user?.displayName || fallbackName}
|
||||||
user?.display_name ||
|
|
||||||
user?.displayName ||
|
|
||||||
displayNpub(pubkey, 16)}
|
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'large') {
|
if (variant === 'large') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
<div className="h-14 w-14 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-14 w-14 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
||||||
@@ -153,7 +168,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-11 w-11 rounded-lg bg-black dark:bg-white"
|
className="h-11 w-11 rounded-lg bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -172,7 +187,7 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'simple') {
|
if (variant === 'simple') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
||||||
@@ -196,7 +211,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -207,7 +222,7 @@ export const User = memo(function User({
|
|||||||
{user?.name || user?.display_name || user?.displayName}
|
{user?.name || user?.display_name || user?.displayName}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="max-w-[10rem] truncate text-sm text-neutral-900 dark:text-neutral-100/70">
|
<p className="max-w-[10rem] truncate text-sm text-neutral-900 dark:text-neutral-100/70">
|
||||||
{user?.nip05 || user?.username || displayNpub(pubkey, 16)}
|
{user?.nip05 || user?.username || fallbackName}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -215,7 +230,7 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'avatar') {
|
if (variant === 'avatar') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="h-12 w-12 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-12 w-12 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
||||||
);
|
);
|
||||||
@@ -232,7 +247,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-12 w-12 rounded-lg bg-black dark:bg-white"
|
className="h-12 w-12 rounded-lg bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -242,7 +257,7 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'miniavatar') {
|
if (variant === 'miniavatar') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
||||||
);
|
);
|
||||||
@@ -259,7 +274,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -269,9 +284,23 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'childnote') {
|
if (variant === 'childnote') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<>
|
||||||
|
<Avatar.Root className="h-10 w-10 shrink-0">
|
||||||
|
<Avatar.Image
|
||||||
|
src={fallbackAvatar}
|
||||||
|
alt={pubkey}
|
||||||
|
className="h-10 w-10 rounded-lg bg-black object-cover dark:bg-white"
|
||||||
|
/>
|
||||||
|
</Avatar.Root>
|
||||||
|
<div className="absolute left-2 top-2 inline-flex items-center gap-1.5 font-semibold leading-tight">
|
||||||
|
<div className="w-full max-w-[10rem] truncate">{fallbackName} </div>
|
||||||
|
<div className="font-normal text-neutral-700 dark:text-neutral-300">
|
||||||
|
{subtext}:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +316,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -295,10 +324,7 @@ export const User = memo(function User({
|
|||||||
</Avatar.Root>
|
</Avatar.Root>
|
||||||
<div className="absolute left-2 top-2 inline-flex items-center gap-1.5 font-semibold leading-tight">
|
<div className="absolute left-2 top-2 inline-flex items-center gap-1.5 font-semibold leading-tight">
|
||||||
<div className="w-full max-w-[10rem] truncate">
|
<div className="w-full max-w-[10rem] truncate">
|
||||||
{user?.display_name ||
|
{user?.display_name || user?.name || user?.displayName || fallbackName}{' '}
|
||||||
user?.name ||
|
|
||||||
user?.displayName ||
|
|
||||||
displayNpub(pubkey, 16)}{' '}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="font-normal text-neutral-700 dark:text-neutral-300">
|
<div className="font-normal text-neutral-700 dark:text-neutral-300">
|
||||||
{subtext}:
|
{subtext}:
|
||||||
@@ -309,7 +335,7 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'stacked') {
|
if (variant === 'stacked') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="inline-block h-8 w-8 animate-pulse rounded-full bg-neutral-300 ring-1 ring-neutral-200 dark:bg-neutral-700 dark:ring-neutral-800" />
|
<div className="inline-block h-8 w-8 animate-pulse rounded-full bg-neutral-300 ring-1 ring-neutral-200 dark:bg-neutral-700 dark:ring-neutral-800" />
|
||||||
);
|
);
|
||||||
@@ -326,7 +352,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="inline-block h-8 w-8 rounded-full bg-black ring-1 ring-neutral-200 dark:bg-white dark:ring-neutral-800"
|
className="inline-block h-8 w-8 rounded-full bg-black ring-1 ring-neutral-200 dark:bg-white dark:ring-neutral-800"
|
||||||
/>
|
/>
|
||||||
@@ -336,7 +362,7 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'ministacked') {
|
if (variant === 'ministacked') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="inline-block h-6 w-6 animate-pulse rounded-full bg-neutral-300 ring-1 ring-white dark:ring-black" />
|
<div className="inline-block h-6 w-6 animate-pulse rounded-full bg-neutral-300 ring-1 ring-white dark:ring-black" />
|
||||||
);
|
);
|
||||||
@@ -353,7 +379,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="inline-block h-6 w-6 rounded-full bg-black ring-1 ring-white dark:bg-white dark:ring-black"
|
className="inline-block h-6 w-6 rounded-full bg-black ring-1 ring-white dark:bg-white dark:ring-black"
|
||||||
/>
|
/>
|
||||||
@@ -363,7 +389,7 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'repost') {
|
if (variant === 'repost') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<div className="inline-flex h-10 w-10 items-center justify-center">
|
<div className="inline-flex h-10 w-10 items-center justify-center">
|
||||||
@@ -389,11 +415,11 @@ export const User = memo(function User({
|
|||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
className="h-6 w-6 rounded"
|
className="h-6 w-6 rounded object-cover"
|
||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-6 w-6 rounded bg-black dark:bg-white"
|
className="h-6 w-6 rounded bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -401,10 +427,7 @@ export const User = memo(function User({
|
|||||||
</Avatar.Root>
|
</Avatar.Root>
|
||||||
<div className="inline-flex items-baseline gap-1">
|
<div className="inline-flex items-baseline gap-1">
|
||||||
<h5 className="max-w-[10rem] truncate font-medium text-neutral-900 dark:text-neutral-100/80">
|
<h5 className="max-w-[10rem] truncate font-medium text-neutral-900 dark:text-neutral-100/80">
|
||||||
{user?.name ||
|
{user?.name || user?.display_name || user?.displayName || fallbackName}
|
||||||
user?.display_name ||
|
|
||||||
user?.displayName ||
|
|
||||||
displayNpub(pubkey, 16)}
|
|
||||||
</h5>
|
</h5>
|
||||||
<span className="text-blue-500">reposted</span>
|
<span className="text-blue-500">reposted</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -414,13 +437,13 @@ export const User = memo(function User({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (variant === 'thread') {
|
if (variant === 'thread') {
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex h-16 items-center gap-3 px-3">
|
||||||
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-10 w-10 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
||||||
<div className="flex flex-1 flex-col">
|
<div className="flex flex-1 flex-col gap-1">
|
||||||
<div className="h-4 w-36 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-4 w-36 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
||||||
<div className="h-4 w-24 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<div className="h-3 w-24 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -434,11 +457,11 @@ export const User = memo(function User({
|
|||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
className="h-10 w-10 rounded-lg ring-1 ring-neutral-200/50 dark:ring-neutral-800/50"
|
className="h-10 w-10 rounded-lg object-cover ring-1 ring-neutral-200/50 dark:ring-neutral-800/50"
|
||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-10 w-10 rounded-lg bg-black ring-1 ring-neutral-200/50 dark:bg-white dark:ring-neutral-800/50"
|
className="h-10 w-10 rounded-lg bg-black ring-1 ring-neutral-200/50 dark:bg-white dark:ring-neutral-800/50"
|
||||||
/>
|
/>
|
||||||
@@ -451,19 +474,27 @@ export const User = memo(function User({
|
|||||||
<div className="inline-flex items-center gap-2 text-sm text-neutral-600 dark:text-neutral-400">
|
<div className="inline-flex items-center gap-2 text-sm text-neutral-600 dark:text-neutral-400">
|
||||||
<span>{createdAt}</span>
|
<span>{createdAt}</span>
|
||||||
<span>·</span>
|
<span>·</span>
|
||||||
<span>{displayNpub(pubkey, 16)}</span>
|
<span>{fallbackName}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status === 'pending') {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3 px-3">
|
<div className="flex items-center gap-3 px-3">
|
||||||
<div className="h-9 w-9 shrink-0 animate-pulse rounded-lg bg-neutral-300 dark:bg-neutral-700" />
|
<Avatar.Root className="h-9 w-9 shrink-0">
|
||||||
|
<Avatar.Image
|
||||||
|
src={fallbackAvatar}
|
||||||
|
alt={pubkey}
|
||||||
|
className="h-9 w-9 rounded-lg bg-black ring-1 ring-neutral-200/50 dark:bg-white dark:ring-neutral-800/50"
|
||||||
|
/>
|
||||||
|
</Avatar.Root>
|
||||||
<div className="h-6 flex-1">
|
<div className="h-6 flex-1">
|
||||||
<div className="h-4 w-36 animate-pulse rounded bg-neutral-300 dark:bg-neutral-700" />
|
<div className="max-w-[15rem] truncate font-semibold text-neutral-950 dark:text-neutral-50">
|
||||||
|
{fallbackName}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -483,7 +514,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-9 w-9 rounded-lg bg-black ring-1 ring-neutral-200/50 dark:bg-white dark:ring-neutral-800/50"
|
className="h-9 w-9 rounded-lg bg-black ring-1 ring-neutral-200/50 dark:bg-white dark:ring-neutral-800/50"
|
||||||
/>
|
/>
|
||||||
@@ -492,10 +523,7 @@ export const User = memo(function User({
|
|||||||
</HoverCard.Trigger>
|
</HoverCard.Trigger>
|
||||||
<div className="flex h-6 flex-1 items-start gap-2">
|
<div className="flex h-6 flex-1 items-start gap-2">
|
||||||
<div className="max-w-[15rem] truncate font-semibold text-neutral-950 dark:text-neutral-50">
|
<div className="max-w-[15rem] truncate font-semibold text-neutral-950 dark:text-neutral-50">
|
||||||
{user?.name ||
|
{user?.name || user?.display_name || user?.displayName || fallbackName}
|
||||||
user?.display_name ||
|
|
||||||
user?.displayName ||
|
|
||||||
displayNpub(pubkey, 16)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="ml-auto inline-flex items-center gap-3">
|
<div className="ml-auto inline-flex items-center gap-3">
|
||||||
<div className="text-neutral-500 dark:text-neutral-400">{createdAt}</div>
|
<div className="text-neutral-500 dark:text-neutral-400">{createdAt}</div>
|
||||||
@@ -515,11 +543,11 @@ export const User = memo(function User({
|
|||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
className="h-10 w-10 rounded-lg"
|
className="h-10 w-10 rounded-lg object-cover"
|
||||||
/>
|
/>
|
||||||
<Avatar.Fallback delayMs={300}>
|
<Avatar.Fallback delayMs={300}>
|
||||||
<img
|
<img
|
||||||
src={svgURI}
|
src={fallbackAvatar}
|
||||||
alt={pubkey}
|
alt={pubkey}
|
||||||
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
||||||
/>
|
/>
|
||||||
@@ -541,7 +569,7 @@ export const User = memo(function User({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="max-w-[15rem] truncate text-sm text-neutral-500 dark:text-neutral-300">
|
<span className="max-w-[15rem] truncate text-sm text-neutral-500 dark:text-neutral-300">
|
||||||
{displayNpub(pubkey, 16)}
|
{fallbackName}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function LiveUpdater({ status }: { status: QueryStatus }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let sub: NDKSubscription = undefined;
|
let sub: NDKSubscription = undefined;
|
||||||
|
|
||||||
if (status === 'success' && db.account && db.account?.follows?.length > 0) {
|
if (status === 'success' && db.account && db.account?.contacts?.length > 0) {
|
||||||
queryClient.fetchQuery({ queryKey: ['notification'] });
|
queryClient.fetchQuery({ queryKey: ['notification'] });
|
||||||
|
|
||||||
const filter: NDKFilter = {
|
const filter: NDKFilter = {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { useNostr } from '@utils/hooks/useNostr';
|
|||||||
import { Widget } from '@utils/types';
|
import { Widget } from '@utils/types';
|
||||||
|
|
||||||
export function ThreadWidget({ widget }: { widget: Widget }) {
|
export function ThreadWidget({ widget }: { widget: Widget }) {
|
||||||
const { status, data } = useEvent(widget.content);
|
const { isFetching, isError, data } = useEvent(widget.content);
|
||||||
const { getEventThread } = useNostr();
|
const { getEventThread } = useNostr();
|
||||||
|
|
||||||
const renderKind = useCallback(
|
const renderKind = useCallback(
|
||||||
@@ -59,16 +59,22 @@ export function ThreadWidget({ widget }: { widget: Widget }) {
|
|||||||
<WidgetWrapper>
|
<WidgetWrapper>
|
||||||
<TitleBar id={widget.id} title={widget.title} />
|
<TitleBar id={widget.id} title={widget.title} />
|
||||||
<WVList className="flex-1 overflow-y-auto px-3 pb-5">
|
<WVList className="flex-1 overflow-y-auto px-3 pb-5">
|
||||||
{status === 'pending' ? (
|
{isFetching ? (
|
||||||
<div className="flex h-16 items-center justify-center rounded-xl bg-neutral-50 px-3 py-3 dark:bg-neutral-950">
|
<div className="flex h-16 items-center justify-center rounded-xl bg-neutral-50 px-3 py-3 dark:bg-neutral-950">
|
||||||
<LoaderIcon className="h-5 w-5 animate-spin" />
|
<LoaderIcon className="h-5 w-5 animate-spin" />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col rounded-xl bg-neutral-50 dark:bg-neutral-950">
|
<div className="flex flex-col rounded-xl bg-neutral-50 dark:bg-neutral-950">
|
||||||
<User pubkey={data.pubkey} time={data.created_at} variant="thread" />
|
{isError ? (
|
||||||
{renderKind(data)}
|
<div>Failed to fetch event</div>
|
||||||
<NoteActions event={data} />
|
) : (
|
||||||
|
<>
|
||||||
|
<User pubkey={data.pubkey} time={data.created_at} variant="thread" />
|
||||||
|
{renderKind(data)}
|
||||||
|
<NoteActions event={data} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<NoteReplyForm rootEvent={data} />
|
<NoteReplyForm rootEvent={data} />
|
||||||
<ReplyList eventId={data.id} />
|
<ReplyList eventId={data.id} />
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
export const FULL_RELAYS = [
|
|
||||||
'wss://relay.damus.io',
|
|
||||||
'wss://relay.nostr.band/all',
|
|
||||||
'wss://nostr.mutinywallet.com',
|
|
||||||
];
|
|
||||||
|
|
||||||
export const FETCH_LIMIT = 20;
|
export const FETCH_LIMIT = 20;
|
||||||
|
|
||||||
export const HASHTAGS = [
|
export const HASHTAGS = [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
import { NDKEvent, NDKSubscriptionCacheUsage, NostrEvent } from '@nostr-dev-kit/ndk';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { AddressPointer } from 'nostr-tools/lib/types/nip19';
|
import { AddressPointer } from 'nostr-tools/lib/types/nip19';
|
||||||
@@ -7,7 +7,7 @@ import { useNDK } from '@libs/ndk/provider';
|
|||||||
|
|
||||||
export function useEvent(id: undefined | string, embed?: undefined | string) {
|
export function useEvent(id: undefined | string, embed?: undefined | string) {
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const { status, data } = useQuery({
|
const { status, isFetching, isError, data } = useQuery({
|
||||||
queryKey: ['event', id],
|
queryKey: ['event', id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const naddr = id.startsWith('naddr')
|
const naddr = id.startsWith('naddr')
|
||||||
@@ -24,27 +24,33 @@ export function useEvent(id: undefined | string, embed?: undefined | string) {
|
|||||||
|
|
||||||
const rEvent = [...rEvents].slice(-1)[0];
|
const rEvent = [...rEvents].slice(-1)[0];
|
||||||
|
|
||||||
if (!rEvent) return Promise.reject(new Error('event not found'));
|
if (!rEvent) throw new Error('event not found');
|
||||||
return rEvent;
|
return rEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return embed event (nostr.band api)
|
// return embed event (nostr.band api)
|
||||||
if (embed) {
|
if (embed) {
|
||||||
const event: NDKEvent = JSON.parse(embed);
|
const embedEvent: NostrEvent = JSON.parse(embed);
|
||||||
return event;
|
const ndkEvent = new NDKEvent(ndk, embedEvent);
|
||||||
|
|
||||||
|
return ndkEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get event from relay
|
// get event from relay
|
||||||
const event = await ndk.fetchEvent(id);
|
const event = await ndk.fetchEvent(id, {
|
||||||
|
cacheUsage: NDKSubscriptionCacheUsage.CACHE_FIRST,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!event)
|
||||||
|
throw new Error(`Cannot get event with ${id}, will be retry after 10 seconds`);
|
||||||
|
|
||||||
if (!event) return Promise.reject(new Error('event not found'));
|
|
||||||
return event;
|
return event;
|
||||||
},
|
},
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
refetchOnReconnect: false,
|
refetchOnReconnect: false,
|
||||||
staleTime: Infinity,
|
retry: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { status, data };
|
return { status, isFetching, isError, data };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,54 @@
|
|||||||
import { NDKUserProfile } from '@nostr-dev-kit/ndk';
|
import { NDKSubscriptionCacheUsage, NDKUserProfile } from '@nostr-dev-kit/ndk';
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
|
|
||||||
import { useNDK } from '@libs/ndk/provider';
|
import { useNDK } from '@libs/ndk/provider';
|
||||||
|
|
||||||
export function useProfile(pubkey: string, embed?: string) {
|
export function useProfile(pubkey: string, embed?: string) {
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const {
|
const {
|
||||||
status,
|
isLoading,
|
||||||
|
isError,
|
||||||
data: user,
|
data: user,
|
||||||
error,
|
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ['user', pubkey],
|
queryKey: ['user', pubkey],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
// parse data from nostr.band api
|
try {
|
||||||
if (embed) {
|
// parse data from nostr.band api
|
||||||
const profile: NDKUserProfile = JSON.parse(embed);
|
if (embed) {
|
||||||
|
const profile: NDKUserProfile = JSON.parse(embed);
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get clean pubkey without any special characters
|
||||||
|
let hexstring = pubkey.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
|
|
||||||
|
if (hexstring.startsWith('npub1') || hexstring.startsWith('nprofile1')) {
|
||||||
|
const decoded = nip19.decode(hexstring);
|
||||||
|
if (decoded.type === 'nprofile') hexstring = decoded.data.pubkey;
|
||||||
|
if (decoded.type === 'npub') hexstring = decoded.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = ndk.getUser({ pubkey: hexstring });
|
||||||
|
const profile = await user.fetchProfile({
|
||||||
|
cacheUsage: NDKSubscriptionCacheUsage.CACHE_FIRST,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!profile)
|
||||||
|
throw new Error(
|
||||||
|
`Cannot get metadata for ${pubkey}, will be retry after 10 seconds`
|
||||||
|
);
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get clean pubkey without any special characters
|
|
||||||
let hexstring = pubkey.replace(/[^a-zA-Z0-9]/g, '');
|
|
||||||
|
|
||||||
if (hexstring.startsWith('npub1') || hexstring.startsWith('nprofile1')) {
|
|
||||||
const decoded = nip19.decode(hexstring);
|
|
||||||
if (decoded.type === 'nprofile') hexstring = decoded.data.pubkey;
|
|
||||||
if (decoded.type === 'npub') hexstring = decoded.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = ndk.getUser({ pubkey: hexstring });
|
|
||||||
const profile = await user.fetchProfile();
|
|
||||||
|
|
||||||
if (!profile)
|
|
||||||
throw new Error(
|
|
||||||
`Cannot get metadata for ${pubkey}, will be retry after 10 seconds`
|
|
||||||
);
|
|
||||||
return profile;
|
|
||||||
},
|
},
|
||||||
initialData: () => queryClient.getQueryData(['user', pubkey]) as NDKUserProfile,
|
refetchOnMount: false,
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
refetchOnReconnect: false,
|
refetchOnReconnect: false,
|
||||||
retry: 2,
|
retry: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { status, user, error };
|
return { isLoading, isError, user };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user