feat(column): add hashtag column
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"build": "vite build"
|
"build": "vite build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@columns/hashtag": "workspace:^",
|
||||||
"@columns/notification": "workspace:^",
|
"@columns/notification": "workspace:^",
|
||||||
"@columns/thread": "workspace:^",
|
"@columns/thread": "workspace:^",
|
||||||
"@columns/timeline": "workspace:^",
|
"@columns/timeline": "workspace:^",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
import { Hashtag } from "@columns/hashtag";
|
||||||
import { Thread } from "@columns/thread";
|
import { Thread } from "@columns/thread";
|
||||||
import { Timeline } from "@columns/timeline";
|
import { Timeline } from "@columns/timeline";
|
||||||
import { User } from "@columns/user";
|
import { User } from "@columns/user";
|
||||||
import { useColumnContext } from "@lume/ark";
|
import { useColumnContext } from "@lume/ark";
|
||||||
import { IColumn } from "@lume/types";
|
import { IColumn } from "@lume/types";
|
||||||
import { WIDGET_KIND } from "@lume/utils";
|
import { COL_TYPES } from "@lume/utils";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { VList, VListHandle } from "virtua";
|
import { VList, VListHandle } from "virtua";
|
||||||
|
|
||||||
@@ -14,12 +15,14 @@ export function HomeScreen() {
|
|||||||
|
|
||||||
const renderItem = (column: IColumn) => {
|
const renderItem = (column: IColumn) => {
|
||||||
switch (column.kind) {
|
switch (column.kind) {
|
||||||
case WIDGET_KIND.newsfeed:
|
case COL_TYPES.newsfeed:
|
||||||
return <Timeline key={column.id} />;
|
return <Timeline key={column.id} />;
|
||||||
case WIDGET_KIND.thread:
|
case COL_TYPES.thread:
|
||||||
return <Thread key={column.id} thread={column} />;
|
return <Thread key={column.id} column={column} />;
|
||||||
case WIDGET_KIND.user:
|
case COL_TYPES.user:
|
||||||
return <User key={column.id} user={column} />;
|
return <User key={column.id} column={column} />;
|
||||||
|
case COL_TYPES.hashtag:
|
||||||
|
return <Hashtag key={column.id} column={column} />;
|
||||||
default:
|
default:
|
||||||
return <Timeline key={column.id} />;
|
return <Timeline key={column.id} />;
|
||||||
}
|
}
|
||||||
@@ -64,7 +67,6 @@ export function HomeScreen() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{columns.map((column) => renderItem(column))}
|
{columns.map((column) => renderItem(column))}
|
||||||
<div className="h-full w-[200px]" />
|
|
||||||
</VList>
|
</VList>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MentionNote, useArk, useSuggestion, useWidget } from "@lume/ark";
|
import { MentionNote, useArk, useSuggestion, useWidget } from "@lume/ark";
|
||||||
import { CancelIcon, LoaderIcon } from "@lume/icons";
|
import { CancelIcon, LoaderIcon } from "@lume/icons";
|
||||||
import { WIDGET_KIND } from "@lume/utils";
|
import { COL_TYPES } from "@lume/utils";
|
||||||
import { NDKKind } from "@nostr-dev-kit/ndk";
|
import { NDKKind } from "@nostr-dev-kit/ndk";
|
||||||
import CharacterCount from "@tiptap/extension-character-count";
|
import CharacterCount from "@tiptap/extension-character-count";
|
||||||
import Image from "@tiptap/extension-image";
|
import Image from "@tiptap/extension-image";
|
||||||
@@ -101,7 +101,7 @@ export function NewPostScreen() {
|
|||||||
addWidget.mutate({
|
addWidget.mutate({
|
||||||
title: "Thread",
|
title: "Thread",
|
||||||
content: publish.id,
|
content: publish.id,
|
||||||
kind: WIDGET_KIND.thread,
|
kind: COL_TYPES.thread,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
packages/@columns/hashtag/package.json
Normal file
26
packages/@columns/hashtag/package.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "@columns/hashtag",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"main": "./src/index.tsx",
|
||||||
|
"dependencies": {
|
||||||
|
"@lume/ark": "workspace:^",
|
||||||
|
"@lume/icons": "workspace:^",
|
||||||
|
"@lume/ui": "workspace:^",
|
||||||
|
"@lume/utils": "workspace:^",
|
||||||
|
"@nostr-dev-kit/ndk": "^2.3.2",
|
||||||
|
"@tanstack/react-query": "^5.15.0",
|
||||||
|
"react": "^18.2.0",
|
||||||
|
"react-router-dom": "^6.21.1",
|
||||||
|
"sonner": "^1.3.1",
|
||||||
|
"virtua": "^0.18.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@lume/tailwindcss": "workspace:^",
|
||||||
|
"@lume/tsconfig": "workspace:^",
|
||||||
|
"@lume/types": "workspace:^",
|
||||||
|
"@types/react": "^18.2.46",
|
||||||
|
"tailwind": "^4.0.0",
|
||||||
|
"typescript": "^5.3.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
29
packages/@columns/hashtag/src/event.tsx
Normal file
29
packages/@columns/hashtag/src/event.tsx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { ThreadNote } from "@lume/ark";
|
||||||
|
import { ArrowLeftIcon } from "@lume/icons";
|
||||||
|
import { ReplyList } from "@lume/ui";
|
||||||
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { WVList } from "virtua";
|
||||||
|
|
||||||
|
export function EventRoute() {
|
||||||
|
const { id } = useParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WVList className="pb-5 overflow-y-auto">
|
||||||
|
<div className="h-11 bg-neutral-50 dark:bg-neutral-950 border-b flex items-center px-3 border-neutral-100 dark:border-neutral-900 mb-3">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex items-center gap-2.5 text-sm font-medium"
|
||||||
|
onClick={() => navigate(-1)}
|
||||||
|
>
|
||||||
|
<ArrowLeftIcon className="size-4" />
|
||||||
|
Back
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="px-3">
|
||||||
|
<ThreadNote eventId={id} />
|
||||||
|
<ReplyList eventId={id} title="All replies" className="mt-5" />
|
||||||
|
</div>
|
||||||
|
</WVList>
|
||||||
|
);
|
||||||
|
}
|
||||||
109
packages/@columns/hashtag/src/home.tsx
Normal file
109
packages/@columns/hashtag/src/home.tsx
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import { TextNote, useArk } from "@lume/ark";
|
||||||
|
import { ArrowRightCircleIcon, LoaderIcon } from "@lume/icons";
|
||||||
|
import { FETCH_LIMIT } from "@lume/utils";
|
||||||
|
import { NDKKind } from "@nostr-dev-kit/ndk";
|
||||||
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||||
|
import { useEffect, useMemo, useRef } from "react";
|
||||||
|
import { CacheSnapshot, VList, VListHandle } from "virtua";
|
||||||
|
|
||||||
|
export function HomeRoute({
|
||||||
|
colKey,
|
||||||
|
hashtag,
|
||||||
|
}: { colKey: string; hashtag: string }) {
|
||||||
|
const ark = useArk();
|
||||||
|
const ref = useRef<VListHandle>();
|
||||||
|
const cacheKey = "hashtag-vlist";
|
||||||
|
|
||||||
|
const [offset, cache] = useMemo(() => {
|
||||||
|
const serialized = sessionStorage.getItem(cacheKey);
|
||||||
|
if (!serialized) return [];
|
||||||
|
return JSON.parse(serialized) as [number, CacheSnapshot];
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const { data, hasNextPage, isLoading, isFetchingNextPage, fetchNextPage } =
|
||||||
|
useInfiniteQuery({
|
||||||
|
queryKey: [colKey],
|
||||||
|
initialPageParam: 0,
|
||||||
|
queryFn: async ({
|
||||||
|
signal,
|
||||||
|
pageParam,
|
||||||
|
}: {
|
||||||
|
signal: AbortSignal;
|
||||||
|
pageParam: number;
|
||||||
|
}) => {
|
||||||
|
const events = await ark.getInfiniteEvents({
|
||||||
|
filter: {
|
||||||
|
kinds: [NDKKind.Text],
|
||||||
|
"#t": [hashtag],
|
||||||
|
},
|
||||||
|
limit: FETCH_LIMIT,
|
||||||
|
pageParam,
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
return events;
|
||||||
|
},
|
||||||
|
getNextPageParam: (lastPage) => {
|
||||||
|
const lastEvent = lastPage.at(-1);
|
||||||
|
if (!lastEvent) return;
|
||||||
|
return lastEvent.created_at - 1;
|
||||||
|
},
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const allEvents = useMemo(
|
||||||
|
() => (data ? data.pages.flatMap((page) => page) : []),
|
||||||
|
[data],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!ref.current) return;
|
||||||
|
const handle = ref.current;
|
||||||
|
|
||||||
|
if (offset) {
|
||||||
|
handle.scrollTo(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
sessionStorage.setItem(
|
||||||
|
cacheKey,
|
||||||
|
JSON.stringify([handle.scrollOffset, handle.cache]),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full h-full">
|
||||||
|
<VList ref={ref} cache={cache} overscan={2} className="flex-1 px-3">
|
||||||
|
{isLoading ? (
|
||||||
|
<div className="w-full flex h-16 items-center justify-center gap-2 px-3 py-1.5">
|
||||||
|
<LoaderIcon className="size-5 animate-spin" />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
allEvents.map((item) => (
|
||||||
|
<TextNote key={item.id} event={item} className="mt-3" />
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
<div className="flex h-16 items-center justify-center">
|
||||||
|
{hasNextPage ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => fetchNextPage()}
|
||||||
|
disabled={!hasNextPage || isFetchingNextPage}
|
||||||
|
className="inline-flex h-10 w-40 items-center justify-center gap-2 rounded-full bg-blue-500 font-medium text-white hover:bg-blue-600 focus:outline-none"
|
||||||
|
>
|
||||||
|
{isFetchingNextPage ? (
|
||||||
|
<LoaderIcon className="h-5 w-5 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<ArrowRightCircleIcon className="h-5 w-5" />
|
||||||
|
Load more
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</VList>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
30
packages/@columns/hashtag/src/index.tsx
Normal file
30
packages/@columns/hashtag/src/index.tsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { Column } from "@lume/ark";
|
||||||
|
import { HashtagIcon, TimelineIcon } from "@lume/icons";
|
||||||
|
import { IColumn } from "@lume/types";
|
||||||
|
import { EventRoute } from "./event";
|
||||||
|
import { HomeRoute } from "./home";
|
||||||
|
import { UserRoute } from "./user";
|
||||||
|
|
||||||
|
export function Hashtag({ column }: { column: IColumn }) {
|
||||||
|
const colKey = "hashtag";
|
||||||
|
const hashtag = column.content.replace("#", "");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Column.Root>
|
||||||
|
<Column.Header
|
||||||
|
id={column.id}
|
||||||
|
queryKey={[colKey]}
|
||||||
|
title={hashtag}
|
||||||
|
icon={<HashtagIcon className="size-4" />}
|
||||||
|
/>
|
||||||
|
<Column.Content>
|
||||||
|
<Column.Route
|
||||||
|
path="/"
|
||||||
|
element={<HomeRoute colKey={colKey} hashtag={hashtag} />}
|
||||||
|
/>
|
||||||
|
<Column.Route path="/events/:id" element={<EventRoute />} />
|
||||||
|
<Column.Route path="/users/:id" element={<UserRoute />} />
|
||||||
|
</Column.Content>
|
||||||
|
</Column.Root>
|
||||||
|
);
|
||||||
|
}
|
||||||
213
packages/@columns/hashtag/src/user.tsx
Normal file
213
packages/@columns/hashtag/src/user.tsx
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
import {
|
||||||
|
RepostNote,
|
||||||
|
TextNote,
|
||||||
|
useArk,
|
||||||
|
useProfile,
|
||||||
|
useStorage,
|
||||||
|
} from "@lume/ark";
|
||||||
|
import { ArrowLeftIcon, ArrowRightCircleIcon, LoaderIcon } from "@lume/icons";
|
||||||
|
import { NIP05 } from "@lume/ui";
|
||||||
|
import { FETCH_LIMIT, displayNpub } from "@lume/utils";
|
||||||
|
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
|
||||||
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { WVList } from "virtua";
|
||||||
|
|
||||||
|
export function UserRoute() {
|
||||||
|
const ark = useArk();
|
||||||
|
const storage = useStorage();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const { id } = useParams();
|
||||||
|
const { user } = useProfile(id);
|
||||||
|
const { data, hasNextPage, isLoading, isFetchingNextPage, fetchNextPage } =
|
||||||
|
useInfiniteQuery({
|
||||||
|
queryKey: ["user-posts", id],
|
||||||
|
initialPageParam: 0,
|
||||||
|
queryFn: async ({
|
||||||
|
signal,
|
||||||
|
pageParam,
|
||||||
|
}: {
|
||||||
|
signal: AbortSignal;
|
||||||
|
pageParam: number;
|
||||||
|
}) => {
|
||||||
|
const events = await ark.getInfiniteEvents({
|
||||||
|
filter: {
|
||||||
|
kinds: [NDKKind.Text, NDKKind.Repost],
|
||||||
|
authors: [id],
|
||||||
|
},
|
||||||
|
limit: FETCH_LIMIT,
|
||||||
|
pageParam,
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
return events;
|
||||||
|
},
|
||||||
|
getNextPageParam: (lastPage) => {
|
||||||
|
const lastEvent = lastPage.at(-1);
|
||||||
|
if (!lastEvent) return;
|
||||||
|
return lastEvent.created_at - 1;
|
||||||
|
},
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [followed, setFollowed] = useState(false);
|
||||||
|
|
||||||
|
const allEvents = useMemo(
|
||||||
|
() => (data ? data.pages.flatMap((page) => page) : []),
|
||||||
|
[data],
|
||||||
|
);
|
||||||
|
|
||||||
|
const follow = async (pubkey: string) => {
|
||||||
|
try {
|
||||||
|
const add = await ark.createContact({ pubkey });
|
||||||
|
if (add) {
|
||||||
|
setFollowed(true);
|
||||||
|
} else {
|
||||||
|
toast.success("You already follow this user");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const unfollow = async (pubkey: string) => {
|
||||||
|
try {
|
||||||
|
const remove = await ark.deleteContact({ pubkey });
|
||||||
|
if (remove) {
|
||||||
|
setFollowed(false);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderItem = (event: NDKEvent) => {
|
||||||
|
switch (event.kind) {
|
||||||
|
case NDKKind.Text:
|
||||||
|
return <TextNote key={event.id} event={event} className="mt-3" />;
|
||||||
|
case NDKKind.Repost:
|
||||||
|
return <RepostNote key={event.id} event={event} className="mt-3" />;
|
||||||
|
default:
|
||||||
|
return <TextNote key={event.id} event={event} className="mt-3" />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (storage.account.contacts.includes(id)) {
|
||||||
|
setFollowed(true);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WVList className="pb-5 overflow-y-auto">
|
||||||
|
<div className="h-11 bg-neutral-50 dark:bg-neutral-950 border-b flex items-center px-3 border-neutral-100 dark:border-neutral-900 mb-3">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex items-center gap-2.5 text-sm font-medium"
|
||||||
|
onClick={() => navigate(-1)}
|
||||||
|
>
|
||||||
|
<ArrowLeftIcon className="size-4" />
|
||||||
|
Back
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="px-3">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<img
|
||||||
|
src={user?.picture || user?.image}
|
||||||
|
alt={id}
|
||||||
|
className="h-12 w-12 shrink-0 rounded-lg object-cover"
|
||||||
|
loading="lazy"
|
||||||
|
decoding="async"
|
||||||
|
/>
|
||||||
|
<div className="inline-flex items-center gap-2">
|
||||||
|
{followed ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => unfollow(id)}
|
||||||
|
className="inline-flex h-9 w-28 items-center justify-center rounded-lg bg-neutral-200 text-sm font-medium hover:bg-blue-500 hover:text-white dark:bg-neutral-800"
|
||||||
|
>
|
||||||
|
Unfollow
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => follow(id)}
|
||||||
|
className="inline-flex h-9 w-28 items-center justify-center rounded-lg bg-neutral-200 text-sm font-medium hover:bg-blue-500 hover:text-white dark:bg-neutral-800"
|
||||||
|
>
|
||||||
|
Follow
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<Link
|
||||||
|
to={`/chats/${id}`}
|
||||||
|
className="inline-flex h-9 w-28 items-center justify-center rounded-lg bg-neutral-200 text-sm font-medium hover:bg-blue-500 hover:text-white dark:bg-neutral-800"
|
||||||
|
>
|
||||||
|
Message
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-1 flex-col gap-1.5">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<h5 className="text-lg font-semibold">
|
||||||
|
{user?.name ||
|
||||||
|
user?.display_name ||
|
||||||
|
user?.displayName ||
|
||||||
|
"Anon"}
|
||||||
|
</h5>
|
||||||
|
{user?.nip05 ? (
|
||||||
|
<NIP05
|
||||||
|
pubkey={id}
|
||||||
|
nip05={user?.nip05}
|
||||||
|
className="max-w-[15rem] truncate text-sm text-neutral-600 dark:text-neutral-400"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<span className="max-w-[15rem] truncate text-sm text-neutral-600 dark:text-neutral-400">
|
||||||
|
{displayNpub(id, 16)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="max-w-[500px] select-text break-words text-neutral-900 dark:text-neutral-100">
|
||||||
|
{user?.about}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="pt-2 mt-2 border-t border-neutral-100 dark:border-neutral-900">
|
||||||
|
<h3 className="text-lg font-semibold text-neutral-900 dark:text-neutral-100">
|
||||||
|
Latest posts
|
||||||
|
</h3>
|
||||||
|
<div className="flex h-full w-full flex-col justify-between gap-1.5 pb-10">
|
||||||
|
{isLoading ? (
|
||||||
|
<div className="flex items-center justify-center">
|
||||||
|
<LoaderIcon className="h-4 w-4 animate-spin" />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
allEvents.map((item) => renderItem(item))
|
||||||
|
)}
|
||||||
|
<div className="flex h-16 items-center justify-center px-3 pb-3">
|
||||||
|
{hasNextPage ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => fetchNextPage()}
|
||||||
|
disabled={!hasNextPage || isFetchingNextPage}
|
||||||
|
className="inline-flex h-10 w-max items-center justify-center gap-2 rounded-full bg-blue-500 px-6 font-medium text-white hover:bg-blue-600 focus:outline-none"
|
||||||
|
>
|
||||||
|
{isFetchingNextPage ? (
|
||||||
|
<LoaderIcon className="h-4 w-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<ArrowRightCircleIcon className="h-5 w-5" />
|
||||||
|
Load more
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</WVList>
|
||||||
|
);
|
||||||
|
}
|
||||||
8
packages/@columns/hashtag/tailwind.config.js
Normal file
8
packages/@columns/hashtag/tailwind.config.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import sharedConfig from "@lume/tailwindcss";
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
content: ["./src/**/*.{js,ts,jsx,tsx}"],
|
||||||
|
presets: [sharedConfig],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
8
packages/@columns/hashtag/tsconfig.json
Normal file
8
packages/@columns/hashtag/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "@lume/tsconfig/base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "dist"
|
||||||
|
},
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import { Column } from "@lume/ark";
|
import { Column } from "@lume/ark";
|
||||||
import { WidgetProps } from "@lume/types";
|
import { IColumn } from "@lume/types";
|
||||||
import { EventRoute } from "./event";
|
import { EventRoute } from "./event";
|
||||||
import { HomeRoute } from "./home";
|
import { HomeRoute } from "./home";
|
||||||
import { UserRoute } from "./user";
|
import { UserRoute } from "./user";
|
||||||
|
|
||||||
export function Thread({ thread }: { thread: WidgetProps }) {
|
export function Thread({ column }: { column: IColumn }) {
|
||||||
return (
|
return (
|
||||||
<Column.Root>
|
<Column.Root>
|
||||||
<Column.Header id={thread.id} title={thread.title} />
|
<Column.Header id={column.id} title={column.title} />
|
||||||
<Column.Content>
|
<Column.Content>
|
||||||
<Column.Route path="/" element={<HomeRoute id={thread.content} />} />
|
<Column.Route path="/" element={<HomeRoute id={column.content} />} />
|
||||||
<Column.Route path="/events/:id" element={<EventRoute />} />
|
<Column.Route path="/events/:id" element={<EventRoute />} />
|
||||||
<Column.Route path="/users/:id" element={<UserRoute />} />
|
<Column.Route path="/users/:id" element={<UserRoute />} />
|
||||||
</Column.Content>
|
</Column.Content>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Note, ThreadNote } from "@lume/ark";
|
import { ThreadNote } from "@lume/ark";
|
||||||
import { ArrowLeftIcon } from "@lume/icons";
|
import { ArrowLeftIcon } from "@lume/icons";
|
||||||
import { ReplyList } from "@lume/ui";
|
import { ReplyList } from "@lume/ui";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { FETCH_LIMIT, displayNpub } from "@lume/utils";
|
|||||||
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
|
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
|
||||||
import { useInfiniteQuery } from "@tanstack/react-query";
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { WVList } from "virtua";
|
import { WVList } from "virtua";
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { Column } from "@lume/ark";
|
import { Column } from "@lume/ark";
|
||||||
import { UserIcon } from "@lume/icons";
|
import { UserIcon } from "@lume/icons";
|
||||||
import { WidgetProps } from "@lume/types";
|
import { IColumn } from "@lume/types";
|
||||||
import { EventRoute } from "./event";
|
import { EventRoute } from "./event";
|
||||||
import { HomeRoute } from "./home";
|
import { HomeRoute } from "./home";
|
||||||
import { UserRoute } from "./user";
|
import { UserRoute } from "./user";
|
||||||
|
|
||||||
export function User({ user }: { user: WidgetProps }) {
|
export function User({ column }: { column: IColumn }) {
|
||||||
return (
|
return (
|
||||||
<Column.Root>
|
<Column.Root>
|
||||||
<Column.Header
|
<Column.Header
|
||||||
id={user.id}
|
id={column.id}
|
||||||
title={user.title}
|
title={column.title}
|
||||||
icon={<UserIcon className="size-4" />}
|
icon={<UserIcon className="size-4" />}
|
||||||
/>
|
/>
|
||||||
<Column.Content>
|
<Column.Content>
|
||||||
<Column.Route path="/" element={<HomeRoute id={user.content} />} />
|
<Column.Route path="/" element={<HomeRoute id={column.content} />} />
|
||||||
<Column.Route path="/events/:id" element={<EventRoute />} />
|
<Column.Route path="/events/:id" element={<EventRoute />} />
|
||||||
<Column.Route path="/users/:id" element={<UserRoute />} />
|
<Column.Route path="/users/:id" element={<UserRoute />} />
|
||||||
</Column.Content>
|
</Column.Content>
|
||||||
|
|||||||
@@ -372,8 +372,6 @@ export class Ark {
|
|||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
dedup?: boolean;
|
dedup?: boolean;
|
||||||
}) {
|
}) {
|
||||||
if (!filter?.authors?.length) return [];
|
|
||||||
|
|
||||||
const rootIds = new Set();
|
const rootIds = new Set();
|
||||||
const dedupQueue = new Set();
|
const dedupQueue = new Set();
|
||||||
const connectedRelays = this.ndk.pool
|
const connectedRelays = this.ndk.pool
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { IColumn } from "@lume/types";
|
import { IColumn } from "@lume/types";
|
||||||
import { WIDGET_KIND } from "@lume/utils";
|
import { COL_TYPES } from "@lume/utils";
|
||||||
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
||||||
import {
|
import {
|
||||||
ReactNode,
|
ReactNode,
|
||||||
@@ -27,7 +27,7 @@ export function ColumnProvider({ children }: { children: ReactNode }) {
|
|||||||
id: "9999",
|
id: "9999",
|
||||||
title: "Newsfeed",
|
title: "Newsfeed",
|
||||||
content: "",
|
content: "",
|
||||||
kind: WIDGET_KIND.newsfeed,
|
kind: COL_TYPES.newsfeed,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { PinIcon } from "@lume/icons";
|
import { PinIcon } from "@lume/icons";
|
||||||
import { WIDGET_KIND } from "@lume/utils";
|
import { COL_TYPES } from "@lume/utils";
|
||||||
import * as Tooltip from "@radix-ui/react-tooltip";
|
import * as Tooltip from "@radix-ui/react-tooltip";
|
||||||
import { useNoteContext } from "..";
|
import { useNoteContext } from "..";
|
||||||
import { useColumnContext } from "../../column";
|
import { useColumnContext } from "../../column";
|
||||||
@@ -16,7 +16,7 @@ export function NotePin() {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
addColumn({
|
addColumn({
|
||||||
kind: WIDGET_KIND.thread,
|
kind: COL_TYPES.thread,
|
||||||
title: "Thread",
|
title: "Thread",
|
||||||
content: event.id,
|
content: event.id,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { WIDGET_KIND } from "@lume/utils";
|
import { COL_TYPES } from "@lume/utils";
|
||||||
import { useColumnContext } from "../../column";
|
import { useColumnContext } from "../../column";
|
||||||
|
|
||||||
export function Hashtag({ tag }: { tag: string }) {
|
export function Hashtag({ tag }: { tag: string }) {
|
||||||
@@ -9,9 +9,9 @@ export function Hashtag({ tag }: { tag: string }) {
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
addColumn({
|
addColumn({
|
||||||
kind: WIDGET_KIND.hashtag,
|
kind: COL_TYPES.hashtag,
|
||||||
title: tag,
|
title: tag,
|
||||||
content: tag.replace("#", ""),
|
content: tag,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
className="cursor-default break-all text-blue-500 hover:text-blue-600"
|
className="cursor-default break-all text-blue-500 hover:text-blue-600"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { WIDGET_KIND } from "@lume/utils";
|
import { COL_TYPES } from "@lume/utils";
|
||||||
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
||||||
import { memo } from "react";
|
import { memo } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
@@ -30,7 +30,7 @@ export const MentionUser = memo(function MentionUser({
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
addColumn({
|
addColumn({
|
||||||
kind: WIDGET_KIND.user,
|
kind: COL_TYPES.user,
|
||||||
title: user?.name || user?.displayName || "",
|
title: user?.name || user?.displayName || "",
|
||||||
content: pubkey,
|
content: pubkey,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { SVGProps } from 'react';
|
import { SVGProps } from "react";
|
||||||
|
|
||||||
export function HashtagIcon(props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>) {
|
export function HashtagIcon(
|
||||||
|
props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -14,9 +16,9 @@ export function HashtagIcon(props: JSX.IntrinsicAttributes & SVGProps<SVGSVGElem
|
|||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
strokeLinecap="round"
|
strokeLinecap="round"
|
||||||
strokeLinejoin="round"
|
strokeLinejoin="round"
|
||||||
strokeWidth="1.5"
|
strokeWidth="2"
|
||||||
d="M8.75 3.75l-2 16.5m10.5-16.5l-2 16.5M3.75 7.75h16.5m0 8.5H3.75"
|
d="M7 20l3-16m4 16l3-16m2.5 11h-16m17-6h-16"
|
||||||
></path>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const HASHTAGS = [
|
|||||||
{ hashtag: "#primal" },
|
{ hashtag: "#primal" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const WIDGET_KIND = {
|
export const COL_TYPES = {
|
||||||
user: 1,
|
user: 1,
|
||||||
thread: 2,
|
thread: 2,
|
||||||
group: 3,
|
group: 3,
|
||||||
|
|||||||
55
pnpm-lock.yaml
generated
55
pnpm-lock.yaml
generated
@@ -20,6 +20,9 @@ importers:
|
|||||||
|
|
||||||
apps/desktop:
|
apps/desktop:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@columns/hashtag':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../packages/@columns/hashtag
|
||||||
'@columns/notification':
|
'@columns/notification':
|
||||||
specifier: workspace:^
|
specifier: workspace:^
|
||||||
version: link:../../packages/@columns/notification
|
version: link:../../packages/@columns/notification
|
||||||
@@ -286,6 +289,58 @@ importers:
|
|||||||
specifier: ^4.2.3
|
specifier: ^4.2.3
|
||||||
version: 4.2.3(typescript@5.3.3)(vite@4.5.1)
|
version: 4.2.3(typescript@5.3.3)(vite@4.5.1)
|
||||||
|
|
||||||
|
packages/@columns/hashtag:
|
||||||
|
dependencies:
|
||||||
|
'@lume/ark':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../ark
|
||||||
|
'@lume/icons':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../icons
|
||||||
|
'@lume/ui':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../ui
|
||||||
|
'@lume/utils':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../utils
|
||||||
|
'@nostr-dev-kit/ndk':
|
||||||
|
specifier: ^2.3.2
|
||||||
|
version: 2.3.2(typescript@5.3.3)
|
||||||
|
'@tanstack/react-query':
|
||||||
|
specifier: ^5.15.0
|
||||||
|
version: 5.15.0(react@18.2.0)
|
||||||
|
react:
|
||||||
|
specifier: ^18.2.0
|
||||||
|
version: 18.2.0
|
||||||
|
react-router-dom:
|
||||||
|
specifier: ^6.21.1
|
||||||
|
version: 6.21.1(react-dom@18.2.0)(react@18.2.0)
|
||||||
|
sonner:
|
||||||
|
specifier: ^1.3.1
|
||||||
|
version: 1.3.1(react-dom@18.2.0)(react@18.2.0)
|
||||||
|
virtua:
|
||||||
|
specifier: ^0.18.0
|
||||||
|
version: 0.18.0(react-dom@18.2.0)(react@18.2.0)
|
||||||
|
devDependencies:
|
||||||
|
'@lume/tailwindcss':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../tailwindcss
|
||||||
|
'@lume/tsconfig':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../tsconfig
|
||||||
|
'@lume/types':
|
||||||
|
specifier: workspace:^
|
||||||
|
version: link:../../types
|
||||||
|
'@types/react':
|
||||||
|
specifier: ^18.2.46
|
||||||
|
version: 18.2.46
|
||||||
|
tailwind:
|
||||||
|
specifier: ^4.0.0
|
||||||
|
version: 4.0.0
|
||||||
|
typescript:
|
||||||
|
specifier: ^5.3.3
|
||||||
|
version: 5.3.3
|
||||||
|
|
||||||
packages/@columns/notification:
|
packages/@columns/notification:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lume/ark':
|
'@lume/ark':
|
||||||
|
|||||||
Reference in New Issue
Block a user