feat: few improvements

This commit is contained in:
reya
2024-07-01 14:41:33 +07:00
parent 843c2d52e7
commit d9fe647f8e
10 changed files with 154 additions and 190 deletions

View File

@@ -44,7 +44,7 @@ export const Column = memo(function Column({
useEffect(() => {
if (!isCreated) return;
const unlisten = listen<WindowEvent>("child-webview", (data) => {
const unlisten = listen<WindowEvent>("child_webview", (data) => {
if (data.payload.scroll) repositionWebview();
if (data.payload.resize) repositionWebview().then(() => resizeWebview());
});
@@ -84,15 +84,8 @@ export const Column = memo(function Column({
}, [account]);
return (
<div className="h-full w-[500px] shrink-0 p-2">
<div
className={cn(
"flex flex-col w-full h-full rounded-xl",
column.label !== "open"
? "bg-black/5 dark:bg-white/10 backdrop-blur"
: "",
)}
>
<div className="h-full w-[480px] shrink-0 p-2">
<div className="flex flex-col w-full h-full rounded-xl bg-black/5 dark:bg-white/10">
<Header label={column.label} name={column.name} />
<div ref={container} className="flex-1 w-full h-full" />
</div>

View File

@@ -118,7 +118,7 @@ export function NoteContent({
<div
className={cn(
"select-text text-pretty content-break overflow-hidden",
event.meta?.content.length > 400
event.meta?.content.length > 500
? "max-h-[250px] gradient-mask-b-0"
: "",
className,

View File

@@ -2,7 +2,6 @@ import { User } from "@/components/user";
import { LinkIcon } from "@lume/icons";
import { LumeWindow, useEvent } from "@lume/system";
import { Spinner } from "@lume/ui";
import { cn } from "@lume/utils";
export function MentionNote({
eventId,

View File

@@ -1,6 +1,6 @@
import { Column } from "@/components/column";
import { Toolbar } from "@/components/toolbar";
import { ArrowLeftIcon, ArrowRightIcon } from "@lume/icons";
import { ArrowLeftIcon, ArrowRightIcon, PlusIcon } from "@lume/icons";
import { NostrQuery } from "@lume/system";
import type { ColumnEvent, LumeColumn } from "@lume/types";
import { createFileRoute } from "@tanstack/react-router";
@@ -38,11 +38,22 @@ function Screen() {
}, [emblaApi]);
const emitScrollEvent = useCallback(() => {
getCurrent().emit("child-webview", { scroll: true });
getCurrent().emit("child_webview", { scroll: true });
}, []);
const emitResizeEvent = useCallback(() => {
getCurrent().emit("child-webview", { resize: true, direction: "x" });
getCurrent().emit("child_webview", { resize: true, direction: "x" });
}, []);
const openLumeStore = useCallback(async () => {
await getCurrent().emit("columns", {
type: "add",
column: {
label: "store",
name: "Store",
content: "/store/official",
},
});
}, []);
const add = useDebouncedCallback((column: LumeColumn) => {
@@ -144,6 +155,18 @@ function Screen() {
account={account}
/>
))}
<div className="shrink-0 p-2 h-full w-[480px]">
<div className="size-full bg-black/5 dark:bg-white/5 rounded-xl flex items-center justify-center">
<button
type="button"
onClick={() => openLumeStore()}
className="inline-flex items-center justify-center gap-0.5 rounded-full text-sm font-medium h-8 w-max pl-1.5 pr-3 bg-black/5 dark:bg-white/5 hover:bg-black/10 dark:hover:bg-white/10"
>
<PlusIcon className="size-5" />
Add Column
</button>
</div>
</div>
</div>
</div>
<Toolbar>

View File

@@ -65,7 +65,6 @@ export function Screen() {
},
getNextPageParam: (lastPage) => lastPage?.at(-1)?.created_at - 1,
select: (data) => data?.pages.flat(),
refetchOnWindowFocus: false,
});
const ref = useRef<HTMLDivElement>(null);
@@ -196,22 +195,16 @@ function Listerner() {
};
useEffect(() => {
const unlistenEvent = getCurrent().listen<Payload>("new_event", (data) => {
const unlisten = getCurrent().listen<Payload>("new_event", (data) => {
const event = LumeEvent.from(data.payload.raw, data.payload.parsed);
setEvents((prev) => [event, ...prev]);
});
const unlistenWindow = getCurrent().onCloseRequested(async () => {
await NostrQuery.unlisten();
await getCurrent().destroy();
});
// Listen for new event
NostrQuery.listenLocalEvent().then(() => console.log("listen"));
return () => {
unlistenEvent.then((f) => f());
unlistenWindow.then((f) => f());
unlisten.then((f) => f());
NostrQuery.unlisten().then(() => console.log("unlisten"));
};
}, []);

View File

@@ -335,7 +335,7 @@ function TextNote({ event }: { event: LumeEvent }) {
Reply to:
</span>
<div className="inline-flex items-baseline gap-1">
{pTags.map((replyTo) => (
{[...new Set(pTags)].map((replyTo) => (
<User.Provider key={replyTo} pubkey={replyTo}>
<User.Root>
<User.Name className="font-medium leading-tight" />