update space screen
This commit is contained in:
@@ -121,15 +121,35 @@ export function NetworkWidget() {
|
|||||||
const filter: NDKFilter = {
|
const filter: NDKFilter = {
|
||||||
kinds: [1, 6],
|
kinds: [1, 6],
|
||||||
authors: db.account.network,
|
authors: db.account.network,
|
||||||
since: Math.floor(Date.now() / 1000),
|
since: db.account.last_login_at ?? Math.floor(Date.now() / 1000),
|
||||||
};
|
};
|
||||||
|
|
||||||
sub(filter, (event) => console.log('[network] event received: ', event.content));
|
sub(filter, async (event) => {
|
||||||
|
console.log('[network] new event', event.id);
|
||||||
|
|
||||||
|
let root: string;
|
||||||
|
let reply: string;
|
||||||
|
if (event.tags?.[0]?.[0] === 'e' && !event.tags?.[0]?.[3]) {
|
||||||
|
root = event.tags[0][1];
|
||||||
|
} else {
|
||||||
|
root = event.tags.find((el) => el[3] === 'root')?.[1];
|
||||||
|
reply = event.tags.find((el) => el[3] === 'reply')?.[1];
|
||||||
|
}
|
||||||
|
await db.createEvent(
|
||||||
|
event.id,
|
||||||
|
JSON.stringify(event),
|
||||||
|
event.pubkey,
|
||||||
|
event.kind,
|
||||||
|
root,
|
||||||
|
reply,
|
||||||
|
event.created_at
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-[400px] shrink-0 bg-white/10">
|
<div className="relative shrink-0 grow-0 basis-[400px] bg-white/10">
|
||||||
<TitleBar title="Network" />
|
<TitleBar title="Network" />
|
||||||
<div ref={parentRef} className="scrollbar-hide h-full overflow-y-auto pb-20">
|
<div ref={parentRef} className="scrollbar-hide h-full overflow-y-auto pb-20">
|
||||||
{status === 'loading' ? (
|
{status === 'loading' ? (
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export function UserWidget({ params }: { params: Widget }) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-[400px] shrink-0 bg-white/10">
|
<div className="relative shrink-0 grow-0 basis-[400px] bg-white/10">
|
||||||
<TitleBar id={params.id} title={params.title} />
|
<TitleBar id={params.id} title={params.title} />
|
||||||
<div ref={parentRef} className="scrollbar-hide h-full overflow-y-auto pb-20">
|
<div ref={parentRef} className="scrollbar-hide h-full overflow-y-auto pb-20">
|
||||||
<div className="px-3 pt-1.5">
|
<div className="px-3 pt-1.5">
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
import { FeedModal } from '@app/space/components/modals/feed';
|
|
||||||
import { HashtagModal } from '@app/space/components/modals/hashtag';
|
|
||||||
import { ImageModal } from '@app/space/components/modals/image';
|
|
||||||
import { FeedWidget } from '@app/space/components/widgets/feed';
|
import { FeedWidget } from '@app/space/components/widgets/feed';
|
||||||
import { HashtagWidget } from '@app/space/components/widgets/hashtag';
|
import { HashtagWidget } from '@app/space/components/widgets/hashtag';
|
||||||
import { NetworkWidget } from '@app/space/components/widgets/network';
|
import { NetworkWidget } from '@app/space/components/widgets/network';
|
||||||
@@ -11,7 +8,7 @@ import { UserWidget } from '@app/space/components/widgets/user';
|
|||||||
|
|
||||||
import { useStorage } from '@libs/storage/provider';
|
import { useStorage } from '@libs/storage/provider';
|
||||||
|
|
||||||
import { LoaderIcon } from '@shared/icons';
|
import { LoaderIcon, PlusIcon } from '@shared/icons';
|
||||||
|
|
||||||
import { useWidgets } from '@stores/widgets';
|
import { useWidgets } from '@stores/widgets';
|
||||||
|
|
||||||
@@ -51,9 +48,9 @@ export function SpaceScreen() {
|
|||||||
}, [fetchWidgets]);
|
}, [fetchWidgets]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="scrollbar-hide flex h-full w-full flex-nowrap divide-x divide-white/5 overflow-x-auto overflow-y-hidden">
|
<div className="scrollbar-hide inline-flex h-full w-full min-w-full flex-nowrap items-start divide-x divide-white/5 overflow-x-auto overflow-y-hidden">
|
||||||
{!widgets ? (
|
{!widgets ? (
|
||||||
<div className="flex w-[400px] shrink-0 flex-col">
|
<div className="flex shrink-0 grow-0 basis-[400px] flex-col">
|
||||||
<div className="flex w-full flex-1 items-center justify-center p-3">
|
<div className="flex w-full flex-1 items-center justify-center p-3">
|
||||||
<LoaderIcon className="h-5 w-5 animate-spin text-white/10" />
|
<LoaderIcon className="h-5 w-5 animate-spin text-white/10" />
|
||||||
</div>
|
</div>
|
||||||
@@ -61,14 +58,16 @@ export function SpaceScreen() {
|
|||||||
) : (
|
) : (
|
||||||
widgets.map((widget) => renderItem(widget))
|
widgets.map((widget) => renderItem(widget))
|
||||||
)}
|
)}
|
||||||
<div className="flex w-[350px] shrink-0 flex-col">
|
<div className="flex h-full shrink-0 grow-0 basis-[400px] flex-col">
|
||||||
<div className="inline-flex h-full w-full flex-col items-center justify-center gap-1">
|
<div className="inline-flex h-full w-full flex-col items-center justify-center">
|
||||||
<FeedModal />
|
<button type="button" className="flex flex-col items-center gap-2">
|
||||||
<ImageModal />
|
<div className="flex h-10 w-10 items-center justify-center rounded-lg bg-white/5 hover:bg-white/10">
|
||||||
<HashtagModal />
|
<PlusIcon className="h-5 w-5 text-white" />
|
||||||
|
</div>
|
||||||
|
<p className="font-medium text-white/50">Add widget</p>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-[250px] shrink-0" />
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.markdown {
|
.markdown {
|
||||||
@apply prose prose-white max-w-none select-text hyphens-auto text-white prose-p:mb-2 prose-p:mt-0 prose-p:break-words prose-p:[word-break:break-word] prose-p:last:mb-0 prose-a:break-words prose-a:break-all prose-a:font-normal prose-a:leading-tight prose-a:after:content-['_↗'] hover:prose-a:text-fuchsia-500 prose-blockquote:m-0 prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:break-all prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-ul:mt-1 prose-li:leading-tight prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2;
|
@apply prose prose-white max-w-none select-text hyphens-auto text-white prose-p:mb-2 prose-p:mt-0 prose-p:break-words prose-p:[word-break:break-word] prose-p:last:mb-0 prose-a:break-words prose-a:break-all prose-a:font-normal prose-a:leading-tight prose-a:after:content-['_↗'] hover:prose-a:text-fuchsia-500 prose-blockquote:mb-1 prose-blockquote:mt-1 prose-blockquote:border-l-[2px] prose-blockquote:border-fuchsia-500 prose-blockquote:pl-2 prose-pre:whitespace-pre-wrap prose-pre:break-words prose-pre:break-all prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-ul:mt-1 prose-li:leading-tight prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ProseMirror p.is-empty::before {
|
.ProseMirror p.is-empty::before {
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ export const MentionNote = memo(function MentionNote({ id }: { id: string }) {
|
|||||||
{isImage(url) && (
|
{isImage(url) && (
|
||||||
<Image
|
<Image
|
||||||
src={url}
|
src={url}
|
||||||
fallback="https://void.cat/d/XTmrMkpid8DGLjv1AzdvcW"
|
|
||||||
alt="image"
|
alt="image"
|
||||||
className="h-auto w-full rounded-lg object-cover"
|
className="h-auto w-full rounded-lg object-cover"
|
||||||
/>
|
/>
|
||||||
@@ -94,7 +93,7 @@ export const MentionNote = memo(function MentionNote({ id }: { id: string }) {
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className="mb-2 mt-3 cursor-default rounded-lg bg-white/10 px-3 py-3"
|
className="mb-2 mt-3 cursor-default rounded-lg bg-white/10 px-3 py-3"
|
||||||
>
|
>
|
||||||
<User pubkey={data.event.pubkey} time={data.event.created_at} size="small" />
|
<User pubkey={data?.event?.pubkey} time={data?.event?.created_at} size="small" />
|
||||||
<div className="mt-2">{renderItem()}</div>
|
<div className="mt-2">{renderItem()}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user