ready for alpha
This commit is contained in:
@@ -2,7 +2,7 @@ import { NDKFilter, NDKKind } from '@nostr-dev-kit/ndk';
|
||||
import * as Avatar from '@radix-ui/react-avatar';
|
||||
import { minidenticon } from 'minidenticons';
|
||||
import { useEffect } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
|
||||
import { useNDK } from '@libs/ndk/provider';
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
@@ -22,14 +22,23 @@ export function ActiveAccount() {
|
||||
const { status, user } = useProfile(db.account.pubkey);
|
||||
const { sub } = useNostr();
|
||||
|
||||
const location = useLocation();
|
||||
const addActivity = useActivities((state) => state.addActivity);
|
||||
const addNewMessage = useActivities((state) => state.addNewMessage);
|
||||
|
||||
const svgURI =
|
||||
'data:image/svg+xml;utf8,' +
|
||||
encodeURIComponent(minidenticon(db.account.pubkey, 90, 50));
|
||||
|
||||
useEffect(() => {
|
||||
const filter: NDKFilter = {
|
||||
kinds: [NDKKind.Text, NDKKind.Repost, NDKKind.Reaction, NDKKind.Zap],
|
||||
kinds: [
|
||||
NDKKind.Text,
|
||||
NDKKind.EncryptedDirectMessage,
|
||||
NDKKind.Repost,
|
||||
NDKKind.Reaction,
|
||||
NDKKind.Zap,
|
||||
],
|
||||
since: Math.floor(Date.now() / 1000),
|
||||
'#p': [db.account.pubkey],
|
||||
};
|
||||
@@ -37,7 +46,11 @@ export function ActiveAccount() {
|
||||
sub(
|
||||
filter,
|
||||
async (event) => {
|
||||
addActivity(event);
|
||||
console.log('receive event: ', event.id);
|
||||
|
||||
if (event.kind !== NDKKind.EncryptedDirectMessage) {
|
||||
addActivity(event);
|
||||
}
|
||||
|
||||
const user = ndk.getUser({ hexpubkey: event.pubkey });
|
||||
await user.fetchProfile();
|
||||
@@ -47,6 +60,18 @@ export function ActiveAccount() {
|
||||
return await sendNativeNotification(
|
||||
`${user.profile.displayName || user.profile.name} has replied to your note`
|
||||
);
|
||||
case NDKKind.EncryptedDirectMessage: {
|
||||
if (location.pathname !== '/chats') {
|
||||
addNewMessage();
|
||||
return await sendNativeNotification(
|
||||
`${
|
||||
user.profile.displayName || user.profile.name
|
||||
} has send you a encrypted message`
|
||||
);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
case NDKKind.Repost:
|
||||
return await sendNativeNotification(
|
||||
`${user.profile.displayName || user.profile.name} has reposted to your note`
|
||||
|
||||
@@ -11,7 +11,13 @@ import {
|
||||
RelayIcon,
|
||||
} from '@shared/icons';
|
||||
|
||||
import { useActivities } from '@stores/activities';
|
||||
|
||||
import { compactNumber } from '@utils/number';
|
||||
|
||||
export function Navigation() {
|
||||
const newMessages = useActivities((state) => state.newMessages);
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full flex-col justify-between p-3">
|
||||
<div className="flex flex-1 flex-col gap-5">
|
||||
@@ -45,13 +51,18 @@ export function Navigation() {
|
||||
<>
|
||||
<div
|
||||
className={twMerge(
|
||||
'inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
'relative inline-flex aspect-square h-auto w-full items-center justify-center rounded-lg',
|
||||
isActive
|
||||
? 'bg-black/10 text-black dark:bg-white/10 dark:text-white'
|
||||
: 'text-black/50 dark:text-neutral-400'
|
||||
)}
|
||||
>
|
||||
<ChatsIcon className="h-6 w-6" />
|
||||
{newMessages > 0 ? (
|
||||
<div className="absolute right-0 top-0 inline-flex h-5 w-5 items-center justify-center rounded-full bg-blue-500 text-[9px] font-medium text-white">
|
||||
{compactNumber.format(newMessages)}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="text-sm font-medium text-black dark:text-white">Chats</div>
|
||||
</>
|
||||
|
||||
@@ -27,3 +27,4 @@ export * from './mentions/invoice';
|
||||
export * from './stats';
|
||||
export * from './wrapper';
|
||||
export * from './actions/more';
|
||||
export * from './replies/replyMediaUploader';
|
||||
|
||||
@@ -30,7 +30,7 @@ export function ArticleDetailNote({ event }: { event: NDKEvent }) {
|
||||
|
||||
return (
|
||||
<ReactMarkdown
|
||||
className="prose prose-neutral max-w-none select-text whitespace-pre-line leading-normal dark:prose-invert prose-headings:mb-1 prose-headings:mt-3 prose-p:mb-0 prose-p:mt-0 prose-p:last:mb-1 prose-a:font-normal prose-a:text-blue-500 prose-blockquote:mb-1 prose-blockquote:mt-1 prose-blockquote:border-l-[2px] prose-blockquote:border-blue-500 prose-blockquote:pl-2 prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:break-all prose-pre:bg-white/10 prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-ul:mt-1 prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2 hover:prose-a:text-blue-500"
|
||||
className="break-p prose prose-neutral max-w-none select-text whitespace-pre-line leading-normal dark:prose-invert prose-headings:mb-1 prose-headings:mt-3 prose-p:mb-0 prose-p:mt-0 prose-p:last:mb-1 prose-a:font-normal prose-a:text-blue-500 prose-blockquote:mb-1 prose-blockquote:mt-1 prose-blockquote:border-l-[2px] prose-blockquote:border-blue-500 prose-blockquote:pl-2 prose-pre:whitespace-pre-wrap prose-pre:bg-white/10 prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-ul:mt-1 prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2 hover:prose-a:text-blue-500"
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
a: ({ href }) => {
|
||||
|
||||
@@ -13,8 +13,6 @@ import {
|
||||
import { memo } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { Image } from '@shared/image';
|
||||
|
||||
import { fileType } from '@utils/nip94';
|
||||
|
||||
export function FileNote(props: { event?: NDKEvent }) {
|
||||
@@ -24,10 +22,13 @@ export function FileNote(props: { event?: NDKEvent }) {
|
||||
if (type === 'image') {
|
||||
return (
|
||||
<div className="mb-2 mt-3">
|
||||
<Image
|
||||
<img
|
||||
src={url}
|
||||
alt={props.event.content}
|
||||
className="h-auto w-full rounded-lg object-cover"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
style={{ contentVisibility: 'auto' }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,25 +1,33 @@
|
||||
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
|
||||
import { useState } from 'react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import { useNDK } from '@libs/ndk/provider';
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
import { ReplyMediaUploader } from '@shared/notes';
|
||||
import { User } from '@shared/user';
|
||||
|
||||
import { useNostr } from '@utils/hooks/useNostr';
|
||||
|
||||
export function NoteReplyForm({ id }: { id: string }) {
|
||||
const { publish } = useNostr();
|
||||
const { db } = useStorage();
|
||||
const { ndk, relayUrls } = useNDK();
|
||||
|
||||
const [value, setValue] = useState('');
|
||||
|
||||
const submit = () => {
|
||||
const tags = [['e', id, '', 'reply']];
|
||||
const submit = async () => {
|
||||
const tags = [['e', id, relayUrls[0], 'root']];
|
||||
|
||||
// publish event
|
||||
publish({ content: value, kind: 1, tags });
|
||||
const event = new NDKEvent(ndk);
|
||||
event.content = value;
|
||||
event.kind = NDKKind.Text;
|
||||
event.tags = tags;
|
||||
|
||||
// reset form
|
||||
setValue('');
|
||||
const publishedRelays = await event.publish();
|
||||
if (publishedRelays) {
|
||||
toast.success(`Broadcasted to ${publishedRelays.size} relays successfully.`);
|
||||
setValue('');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -30,16 +38,19 @@ export function NoteReplyForm({ id }: { id: string }) {
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
placeholder="Reply to this thread..."
|
||||
className="relative h-24 w-full resize-none bg-transparent p-3 text-base text-neutral-900 !outline-none placeholder:text-neutral-600 dark:text-neutral-100 dark:placeholder:text-neutral-400"
|
||||
className="relative h-36 w-full resize-none bg-transparent px-5 py-4 text-neutral-900 !outline-none placeholder:text-neutral-600 dark:text-neutral-100 dark:placeholder:text-neutral-400"
|
||||
spellCheck={false}
|
||||
/>
|
||||
<button
|
||||
onClick={() => submit()}
|
||||
disabled={value.length === 0 ? true : false}
|
||||
className="mb-2 ml-auto mr-2 h-9 w-20 rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50"
|
||||
>
|
||||
Reply
|
||||
</button>
|
||||
<div className="inline-flex items-center justify-end gap-2 rounded-b-xl border-t border-neutral-200 p-2 dark:border-neutral-800">
|
||||
<ReplyMediaUploader setValue={setValue} />
|
||||
<button
|
||||
onClick={() => submit()}
|
||||
disabled={value.length === 0 ? true : false}
|
||||
className="h-9 w-20 rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50"
|
||||
>
|
||||
Reply
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ export function Reply({ event, root }: { event: NDKEventWithReplies; root?: stri
|
||||
<User pubkey={event.pubkey} time={event.created_at} eventId={event.id} />
|
||||
<div className="-mt-4 flex items-start gap-3">
|
||||
<div className="w-10 shrink-0" />
|
||||
<div className="flex-1">
|
||||
<div className="relative z-10 flex-1">
|
||||
<MemoizedTextNote content={event.content} />
|
||||
<NoteActions
|
||||
id={event.id}
|
||||
|
||||
@@ -48,7 +48,7 @@ export function ReplyList({ id }: { id: string }) {
|
||||
return (
|
||||
<div className="mt-3 flex flex-col gap-5">
|
||||
{data?.length === 0 ? (
|
||||
<div className="mt-2 flex w-full items-center justify-center rounded-xl bg-neutral-400 dark:bg-neutral-600">
|
||||
<div className="mt-2 flex w-full items-center justify-center">
|
||||
<div className="flex flex-col items-center justify-center gap-2 py-6">
|
||||
<h3 className="text-3xl">👋</h3>
|
||||
<p className="leading-none text-neutral-600 dark:text-neutral-400">
|
||||
|
||||
79
src/shared/notes/replies/replyMediaUploader.tsx
Normal file
79
src/shared/notes/replies/replyMediaUploader.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { message, open } from '@tauri-apps/plugin-dialog';
|
||||
import { readBinaryFile } from '@tauri-apps/plugin-fs';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { MediaIcon } from '@shared/icons';
|
||||
|
||||
export function ReplyMediaUploader({ setValue }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const uploadToNostrBuild = async () => {
|
||||
try {
|
||||
// start loading
|
||||
setLoading(true);
|
||||
|
||||
const selected = await open({
|
||||
multiple: false,
|
||||
filters: [
|
||||
{
|
||||
name: 'Media',
|
||||
extensions: [
|
||||
'png',
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'gif',
|
||||
'mp4',
|
||||
'mp3',
|
||||
'webm',
|
||||
'mkv',
|
||||
'avi',
|
||||
'mov',
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (!selected) {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const file = await readBinaryFile(selected.path);
|
||||
const blob = new Blob([file]);
|
||||
|
||||
const data = new FormData();
|
||||
data.append('fileToUpload', blob);
|
||||
data.append('submit', 'Upload Image');
|
||||
|
||||
const res = await fetch('https://nostr.build/api/v2/upload/files', {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const json = await res.json();
|
||||
const content = json.data[0];
|
||||
|
||||
setValue((prev) => prev + ' ' + content.url);
|
||||
|
||||
// stop loading
|
||||
setLoading(false);
|
||||
}
|
||||
} catch (e) {
|
||||
// stop loading
|
||||
setLoading(false);
|
||||
await message(`Upload failed, error: ${e}`, { title: 'Lume', type: 'error' });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => uploadToNostrBuild()}
|
||||
className="inline-flex h-9 w-max items-center justify-center gap-1.5 rounded-lg bg-neutral-100 px-2 text-sm font-medium text-neutral-900 hover:bg-neutral-200 dark:bg-neutral-900 dark:text-neutral-100 dark:hover:bg-neutral-800"
|
||||
>
|
||||
<MediaIcon className="h-5 w-5" />
|
||||
{loading ? 'Uploading...' : 'Add media'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -1,33 +1,38 @@
|
||||
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
|
||||
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
import {
|
||||
ArticleNote,
|
||||
FileNote,
|
||||
NoteActions,
|
||||
NoteSkeleton,
|
||||
TextNote,
|
||||
UnknownNote,
|
||||
} from '@shared/notes';
|
||||
import { User } from '@shared/user';
|
||||
|
||||
import { WidgetKinds, useWidgets } from '@stores/widgets';
|
||||
|
||||
import { formatCreatedAt } from '@utils/createdAt';
|
||||
import { useEvent } from '@utils/hooks/useEvent';
|
||||
|
||||
export function NotifyNote({
|
||||
id,
|
||||
user,
|
||||
content,
|
||||
kind,
|
||||
time,
|
||||
}: {
|
||||
id: string;
|
||||
user: string;
|
||||
content: string;
|
||||
kind: NDKKind | number;
|
||||
time: number;
|
||||
}) {
|
||||
const createdAt = formatCreatedAt(time, false);
|
||||
const { status, data } = useEvent(id);
|
||||
export function NotifyNote({ event }: { event: NDKEvent }) {
|
||||
const createdAt = formatCreatedAt(event.created_at, false);
|
||||
const rootEventId = event.tags.find((el) => el[0] === 'e')?.[1];
|
||||
|
||||
const { db } = useStorage();
|
||||
const { status, data } = useEvent(rootEventId);
|
||||
|
||||
const setWidget = useWidgets((state) => state.setWidget);
|
||||
|
||||
const openThread = (event, thread: string) => {
|
||||
const selection = window.getSelection();
|
||||
if (selection.toString().length === 0) {
|
||||
setWidget(db, { kind: WidgetKinds.local.thread, title: 'Thread', content: thread });
|
||||
} else {
|
||||
event.stopPropagation();
|
||||
}
|
||||
};
|
||||
|
||||
const renderKind = (event: NDKEvent) => {
|
||||
switch (event.kind) {
|
||||
@@ -47,7 +52,7 @@ export function NotifyNote({
|
||||
case NDKKind.Text:
|
||||
return 'replied';
|
||||
case NDKKind.Reaction:
|
||||
return `reacted ${content}`;
|
||||
return `reacted ${event.content}`;
|
||||
case NDKKind.Repost:
|
||||
return 'reposted';
|
||||
case NDKKind.Zap:
|
||||
@@ -68,28 +73,29 @@ export function NotifyNote({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mb-5 flex h-min w-full flex-col gap-2 px-3 pb-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<User pubkey={user} variant="notify" />
|
||||
<p className="font-medium text-neutral-600 dark:text-neutral-400">
|
||||
{renderText(kind)}
|
||||
</p>
|
||||
</div>
|
||||
<span className="font-medium text-neutral-600 dark:text-neutral-400">
|
||||
{createdAt}
|
||||
</span>
|
||||
</div>
|
||||
<div className="relative overflow-hidden rounded-xl bg-neutral-100 px-3 py-4 dark:bg-neutral-900">
|
||||
<div className="relative flex flex-col">
|
||||
<User pubkey={data.pubkey} time={data.created_at} eventId={data.id} />
|
||||
<div className="-mt-4 flex items-start gap-3">
|
||||
<div className="w-10 shrink-0" />
|
||||
<div className="relative z-20 flex-1">
|
||||
{renderKind(data)}
|
||||
<NoteActions id={data.id} pubkey={data.pubkey} />
|
||||
<div className="h-min w-full px-3 pb-3">
|
||||
<div className="flex flex-col gap-2 rounded-xl bg-neutral-100 p-3 dark:bg-neutral-900">
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<User pubkey={event.pubkey} variant="notify" />
|
||||
<p className="font-medium text-neutral-600 dark:text-neutral-400">
|
||||
{renderText(event.kind)}
|
||||
</p>
|
||||
</div>
|
||||
<span className="text-neutral-500 dark:text-neutral-400">{createdAt}</span>
|
||||
</div>
|
||||
{event.kind === 1 ? <TextNote content={event.content} /> : null}
|
||||
</div>
|
||||
<div
|
||||
onClick={(e) => openThread(e, data.id)}
|
||||
onKeyDown={(e) => openThread(e, data.id)}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
className="cursor-default rounded-lg border border-neutral-300 bg-neutral-200 p-3 dark:border-neutral-700 dark:bg-neutral-800"
|
||||
>
|
||||
<User pubkey={data.pubkey} time={data.created_at} variant="mention" />
|
||||
<div className="mt-1">{renderKind(data)}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -115,13 +115,13 @@ export const User = memo(function User({
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
style={{ contentVisibility: 'auto' }}
|
||||
className="h-8 w-8 rounded-lg"
|
||||
className="h-8 w-8 rounded-md"
|
||||
/>
|
||||
<Avatar.Fallback delayMs={300}>
|
||||
<img
|
||||
src={svgURI}
|
||||
alt={pubkey}
|
||||
className="h-8 w-8 rounded-lg bg-black dark:bg-white"
|
||||
className="h-8 w-8 rounded-md bg-black dark:bg-white"
|
||||
/>
|
||||
</Avatar.Fallback>
|
||||
</Avatar.Root>
|
||||
@@ -416,10 +416,10 @@ export const User = memo(function User({
|
||||
</div>
|
||||
<HoverCard.Portal>
|
||||
<HoverCard.Content
|
||||
className="w-[300px] overflow-hidden rounded-xl border border-white/10 bg-white/10 backdrop-blur-3xl data-[side=bottom]:animate-slideUpAndFade data-[side=left]:animate-slideRightAndFade data-[side=right]:animate-slideLeftAndFade data-[side=top]:animate-slideDownAndFade data-[state=open]:transition-all focus:outline-none"
|
||||
className="ml-4 w-[300px] overflow-hidden rounded-xl border border-neutral-200 bg-neutral-100 shadow-lg data-[side=bottom]:animate-slideUpAndFade data-[side=left]:animate-slideRightAndFade data-[side=right]:animate-slideLeftAndFade data-[side=top]:animate-slideDownAndFade data-[state=open]:transition-all focus:outline-none dark:border-neutral-800 dark:bg-neutral-900"
|
||||
sideOffset={5}
|
||||
>
|
||||
<div className="flex gap-2.5 border-b border-white/5 px-3 py-3">
|
||||
<div className="flex gap-2.5 border-b border-neutral-200 px-3 py-3 dark:border-neutral-800">
|
||||
<Avatar.Root className="shrink-0">
|
||||
<Avatar.Image
|
||||
src={user?.picture || user?.image}
|
||||
@@ -427,13 +427,13 @@ export const User = memo(function User({
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
style={{ contentVisibility: 'auto' }}
|
||||
className="h-10 w-10 rounded-lg border border-white/5"
|
||||
className="h-10 w-10 rounded-lg"
|
||||
/>
|
||||
<Avatar.Fallback delayMs={300}>
|
||||
<img
|
||||
src={svgURI}
|
||||
alt={pubkey}
|
||||
className="h-10 w-10 rounded-lg border border-white/5 bg-black dark:bg-white"
|
||||
className="h-10 w-10 rounded-lg bg-black dark:bg-white"
|
||||
/>
|
||||
</Avatar.Fallback>
|
||||
</Avatar.Root>
|
||||
@@ -467,13 +467,13 @@ export const User = memo(function User({
|
||||
<div className="flex items-center gap-2 px-3 py-3">
|
||||
<Link
|
||||
to={`/users/${pubkey}`}
|
||||
className="inline-flex h-10 flex-1 items-center justify-center rounded-md bg-white/10 text-sm font-semibold backdrop-blur-xl hover:bg-blue-600"
|
||||
className="inline-flex h-9 flex-1 items-center justify-center rounded-lg bg-neutral-200 text-sm font-semibold hover:bg-blue-500 hover:text-white dark:bg-neutral-800"
|
||||
>
|
||||
View profile
|
||||
</Link>
|
||||
<Link
|
||||
to={`/chats/${pubkey}`}
|
||||
className="inline-flex h-10 flex-1 items-center justify-center rounded-md bg-white/10 text-sm font-semibold backdrop-blur-xl hover:bg-blue-600"
|
||||
className="inline-flex h-9 flex-1 items-center justify-center rounded-lg bg-neutral-200 text-sm font-semibold hover:bg-blue-500 hover:text-white dark:bg-neutral-800"
|
||||
>
|
||||
Message
|
||||
</Link>
|
||||
|
||||
@@ -67,9 +67,9 @@ export function GlobalArticlesWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{data.map((item) => renderItem(item))}
|
||||
<div className="h-16" />
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -69,9 +69,9 @@ export function GlobalFilesWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{data.map((item) => renderItem(item))}
|
||||
<div className="h-16" />
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -99,7 +99,7 @@ export function GlobalHashtagWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{data.map((item) => renderItem(item))}
|
||||
<div className="h-16" />
|
||||
</VList>
|
||||
|
||||
@@ -69,7 +69,7 @@ export function LocalArticlesWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{dbEvents.map((item) => renderItem(item))}
|
||||
<div className="flex items-center justify-center px-3 py-1.5">
|
||||
{dbEvents.length > 0 ? (
|
||||
@@ -97,7 +97,7 @@ export function LocalArticlesWidget({ params }: { params: Widget }) {
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="h-16" />
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -105,7 +105,7 @@ export function LocalFeedsWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{dbEvents.map((item) => renderItem(item))}
|
||||
<div className="flex items-center justify-center px-3 py-1.5">
|
||||
{dbEvents.length > 0 ? (
|
||||
@@ -133,7 +133,7 @@ export function LocalFeedsWidget({ params }: { params: Widget }) {
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="h-16" />
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -69,7 +69,7 @@ export function LocalFilesWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{dbEvents.map((item) => renderItem(item))}
|
||||
<div className="flex items-center justify-center px-3 py-1.5">
|
||||
{dbEvents.length > 0 ? (
|
||||
@@ -97,7 +97,7 @@ export function LocalFilesWidget({ params }: { params: Widget }) {
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="h-16" />
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -104,7 +104,7 @@ export function LocalFollowsWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{dbEvents.map((item) => renderItem(item))}
|
||||
<div className="flex items-center justify-center px-3 py-1.5">
|
||||
{dbEvents.length > 0 ? (
|
||||
@@ -132,7 +132,7 @@ export function LocalFollowsWidget({ params }: { params: Widget }) {
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="h-16" />
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -145,7 +145,7 @@ export function LocalNetworkWidget() {
|
||||
) : dbEvents.length === 0 ? (
|
||||
<EventLoader firstTime={true} />
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{!isFetched ? <EventLoader firstTime={false} /> : null}
|
||||
{dbEvents.map((item) => renderItem(item))}
|
||||
<div className="flex items-center justify-center px-3 py-1.5">
|
||||
|
||||
@@ -25,18 +25,8 @@ export function LocalNotificationWidget({ params }: { params: Widget }) {
|
||||
|
||||
const renderEvent = useCallback(
|
||||
(event: NDKEvent) => {
|
||||
const rootEventId = event.tags.find((el) => el[0] === 'e')?.[1];
|
||||
if (!rootEventId) return null;
|
||||
if (event.pubkey === db.account.pubkey) return null;
|
||||
return (
|
||||
<NotifyNote
|
||||
id={rootEventId}
|
||||
user={event.pubkey}
|
||||
content={event.content}
|
||||
kind={event.kind}
|
||||
time={event.created_at}
|
||||
/>
|
||||
);
|
||||
return <NotifyNote key={event.id} event={event} />;
|
||||
},
|
||||
[activities]
|
||||
);
|
||||
@@ -53,7 +43,7 @@ export function LocalNotificationWidget({ params }: { params: Widget }) {
|
||||
return (
|
||||
<WidgetWrapper>
|
||||
<TitleBar id={params.id} title={params.title} />
|
||||
<div className="h-full px-3">
|
||||
<div className="flex-1">
|
||||
{!activities ? (
|
||||
<div className="flex h-full w-full items-center justify-center">
|
||||
<div className="flex flex-col items-center gap-1.5">
|
||||
@@ -71,8 +61,9 @@ export function LocalNotificationWidget({ params }: { params: Widget }) {
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full overflow-y-auto scrollbar-none">
|
||||
<VList className="h-full" style={{ contentVisibility: 'auto' }}>
|
||||
{activities.map((event) => renderEvent(event))}
|
||||
<div className="h-14" />
|
||||
</VList>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
|
||||
import { useCallback } from 'react';
|
||||
import { WVList } from 'virtua';
|
||||
|
||||
import { LoaderIcon } from '@shared/icons';
|
||||
import {
|
||||
@@ -41,7 +42,7 @@ export function LocalThreadWidget({ params }: { params: Widget }) {
|
||||
return (
|
||||
<WidgetWrapper>
|
||||
<TitleBar id={params.id} title={params.title} />
|
||||
<div className="h-full overflow-y-auto px-3 scrollbar-none">
|
||||
<WVList className="flex-1 overflow-y-auto px-3">
|
||||
{status === 'loading' ? (
|
||||
<div className="flex h-16 items-center justify-center rounded-xl bg-neutral-100 px-3 py-3 dark:bg-neutral-900">
|
||||
<LoaderIcon className="h-5 w-5 animate-spin" />
|
||||
@@ -58,7 +59,7 @@ export function LocalThreadWidget({ params }: { params: Widget }) {
|
||||
<NoteReplyForm id={params.content} />
|
||||
<ReplyList id={params.content} />
|
||||
<div className="h-10" />
|
||||
</div>
|
||||
</WVList>
|
||||
</WidgetWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export function LocalUserWidget({ params }: { params: Widget }) {
|
||||
return (
|
||||
<WidgetWrapper>
|
||||
<TitleBar id={params.id} title={params.title} />
|
||||
<div className="h-full overflow-y-auto scrollbar-none">
|
||||
<WVList className="flex-1 overflow-y-auto">
|
||||
<div className="px-3 pt-1.5">
|
||||
<UserProfile pubkey={params.content} />
|
||||
</div>
|
||||
@@ -107,11 +107,11 @@ export function LocalUserWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<WVList>{data.map((item) => renderItem(item))}</WVList>
|
||||
data.map((item) => renderItem(item))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</WVList>
|
||||
</WidgetWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export function TrendingAccountsWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full">
|
||||
{data.map((item: Profile) => (
|
||||
<NostrBandUserProfile key={item.pubkey} data={item} />
|
||||
))}
|
||||
|
||||
@@ -58,7 +58,7 @@ export function TrendingNotesWidget({ params }: { params: Widget }) {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<VList className="h-full scrollbar-none">
|
||||
<VList className="h-full">
|
||||
{data.map((item) => (
|
||||
<NoteWrapper key={item.event.id} event={item.event}>
|
||||
<TextNote content={item.event.content} />
|
||||
|
||||
@@ -21,7 +21,7 @@ export function WidgetWrapper({
|
||||
minWidth={420}
|
||||
maxWidth={600}
|
||||
className={twMerge(
|
||||
'flex flex-col border-r border-neutral-100 dark:border-neutral-900',
|
||||
'flex flex-col border-r-2 border-neutral-50 hover:border-neutral-100 dark:border-neutral-950 dark:hover:border-neutral-900',
|
||||
className
|
||||
)}
|
||||
enable={{ right: true }}
|
||||
|
||||
Reference in New Issue
Block a user