feat: few improvements
This commit is contained in:
@@ -44,7 +44,7 @@ export const Column = memo(function Column({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isCreated) return;
|
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.scroll) repositionWebview();
|
||||||
if (data.payload.resize) repositionWebview().then(() => resizeWebview());
|
if (data.payload.resize) repositionWebview().then(() => resizeWebview());
|
||||||
});
|
});
|
||||||
@@ -84,15 +84,8 @@ export const Column = memo(function Column({
|
|||||||
}, [account]);
|
}, [account]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full w-[500px] shrink-0 p-2">
|
<div className="h-full w-[480px] shrink-0 p-2">
|
||||||
<div
|
<div className="flex flex-col w-full h-full rounded-xl bg-black/5 dark:bg-white/10">
|
||||||
className={cn(
|
|
||||||
"flex flex-col w-full h-full rounded-xl",
|
|
||||||
column.label !== "open"
|
|
||||||
? "bg-black/5 dark:bg-white/10 backdrop-blur"
|
|
||||||
: "",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Header label={column.label} name={column.name} />
|
<Header label={column.label} name={column.name} />
|
||||||
<div ref={container} className="flex-1 w-full h-full" />
|
<div ref={container} className="flex-1 w-full h-full" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export function NoteContent({
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"select-text text-pretty content-break overflow-hidden",
|
"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"
|
? "max-h-[250px] gradient-mask-b-0"
|
||||||
: "",
|
: "",
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { User } from "@/components/user";
|
|||||||
import { LinkIcon } from "@lume/icons";
|
import { LinkIcon } from "@lume/icons";
|
||||||
import { LumeWindow, useEvent } from "@lume/system";
|
import { LumeWindow, useEvent } from "@lume/system";
|
||||||
import { Spinner } from "@lume/ui";
|
import { Spinner } from "@lume/ui";
|
||||||
import { cn } from "@lume/utils";
|
|
||||||
|
|
||||||
export function MentionNote({
|
export function MentionNote({
|
||||||
eventId,
|
eventId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Column } from "@/components/column";
|
import { Column } from "@/components/column";
|
||||||
import { Toolbar } from "@/components/toolbar";
|
import { Toolbar } from "@/components/toolbar";
|
||||||
import { ArrowLeftIcon, ArrowRightIcon } from "@lume/icons";
|
import { ArrowLeftIcon, ArrowRightIcon, PlusIcon } from "@lume/icons";
|
||||||
import { NostrQuery } from "@lume/system";
|
import { NostrQuery } from "@lume/system";
|
||||||
import type { ColumnEvent, LumeColumn } from "@lume/types";
|
import type { ColumnEvent, LumeColumn } from "@lume/types";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
@@ -38,11 +38,22 @@ function Screen() {
|
|||||||
}, [emblaApi]);
|
}, [emblaApi]);
|
||||||
|
|
||||||
const emitScrollEvent = useCallback(() => {
|
const emitScrollEvent = useCallback(() => {
|
||||||
getCurrent().emit("child-webview", { scroll: true });
|
getCurrent().emit("child_webview", { scroll: true });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const emitResizeEvent = useCallback(() => {
|
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) => {
|
const add = useDebouncedCallback((column: LumeColumn) => {
|
||||||
@@ -144,6 +155,18 @@ function Screen() {
|
|||||||
account={account}
|
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>
|
||||||
</div>
|
</div>
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ export function Screen() {
|
|||||||
},
|
},
|
||||||
getNextPageParam: (lastPage) => lastPage?.at(-1)?.created_at - 1,
|
getNextPageParam: (lastPage) => lastPage?.at(-1)?.created_at - 1,
|
||||||
select: (data) => data?.pages.flat(),
|
select: (data) => data?.pages.flat(),
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
@@ -196,22 +195,16 @@ function Listerner() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
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);
|
const event = LumeEvent.from(data.payload.raw, data.payload.parsed);
|
||||||
setEvents((prev) => [event, ...prev]);
|
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"));
|
NostrQuery.listenLocalEvent().then(() => console.log("listen"));
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
unlistenEvent.then((f) => f());
|
unlisten.then((f) => f());
|
||||||
unlistenWindow.then((f) => f());
|
NostrQuery.unlisten().then(() => console.log("unlisten"));
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ function TextNote({ event }: { event: LumeEvent }) {
|
|||||||
Reply to:
|
Reply to:
|
||||||
</span>
|
</span>
|
||||||
<div className="inline-flex items-baseline gap-1">
|
<div className="inline-flex items-baseline gap-1">
|
||||||
{pTags.map((replyTo) => (
|
{[...new Set(pTags)].map((replyTo) => (
|
||||||
<User.Provider key={replyTo} pubkey={replyTo}>
|
<User.Provider key={replyTo} pubkey={replyTo}>
|
||||||
<User.Root>
|
<User.Root>
|
||||||
<User.Name className="font-medium leading-tight" />
|
<User.Name className="font-medium leading-tight" />
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import type { Metadata } from "@lume/types";
|
import type { Metadata } from "@lume/types";
|
||||||
import { type Result, commands } from "./commands";
|
import { type Result, commands } from "./commands";
|
||||||
|
|
||||||
export class NostrAccount {
|
export const NostrAccount = {
|
||||||
static async getAccounts() {
|
getAccounts: async () => {
|
||||||
const query = await commands.getAccounts();
|
const query = await commands.getAccounts();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -10,9 +10,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
loadAccount: async (npub: string) => {
|
||||||
static async loadAccount(npub: string) {
|
|
||||||
const bunker: string = localStorage.getItem(`${npub}_bunker`);
|
const bunker: string = localStorage.getItem(`${npub}_bunker`);
|
||||||
let query: Result<boolean, string>;
|
let query: Result<boolean, string>;
|
||||||
|
|
||||||
@@ -27,9 +26,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
createAccount: async () => {
|
||||||
static async createAccount() {
|
|
||||||
const query = await commands.createAccount();
|
const query = await commands.createAccount();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -37,9 +35,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
createProfile: async (profile: Metadata) => {
|
||||||
static async createProfile(profile: Metadata) {
|
|
||||||
const query = await commands.createProfile(
|
const query = await commands.createProfile(
|
||||||
profile.name || "",
|
profile.name || "",
|
||||||
profile.display_name || "",
|
profile.display_name || "",
|
||||||
@@ -56,9 +53,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
saveAccount: async (nsec: string, password = "") => {
|
||||||
static async saveAccount(nsec: string, password = "") {
|
|
||||||
const query = await commands.saveAccount(nsec, password);
|
const query = await commands.saveAccount(nsec, password);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -66,9 +62,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
connectRemoteAccount: async (uri: string) => {
|
||||||
static async connectRemoteAccount(uri: string) {
|
|
||||||
const connect = await commands.connectRemoteAccount(uri);
|
const connect = await commands.connectRemoteAccount(uri);
|
||||||
|
|
||||||
if (connect.status === "ok") {
|
if (connect.status === "ok") {
|
||||||
@@ -83,9 +78,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(connect.error);
|
throw new Error(connect.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
setContactList: async (pubkeys: string[]) => {
|
||||||
static async setContactList(pubkeys: string[]) {
|
|
||||||
const query = await commands.setContactList(pubkeys);
|
const query = await commands.setContactList(pubkeys);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -93,9 +87,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
loadWallet: async () => {
|
||||||
static async loadWallet() {
|
|
||||||
const query = await commands.loadWallet();
|
const query = await commands.loadWallet();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -103,9 +96,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
setWallet: async (uri: string) => {
|
||||||
static async setWallet(uri: string) {
|
|
||||||
const query = await commands.setWallet(uri);
|
const query = await commands.setWallet(uri);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -113,9 +105,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
removeWallet: async () => {
|
||||||
static async removeWallet() {
|
|
||||||
const query = await commands.removeWallet();
|
const query = await commands.removeWallet();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -123,9 +114,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getProfile: async () => {
|
||||||
static async getProfile() {
|
|
||||||
const query = await commands.getCurrentProfile();
|
const query = await commands.getCurrentProfile();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -133,9 +123,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getContactList: async () => {
|
||||||
static async getContactList() {
|
|
||||||
const query = await commands.getContactList();
|
const query = await commands.getContactList();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -143,9 +132,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
isContactListEmpty: async () => {
|
||||||
static async isContactListEmpty() {
|
|
||||||
const query = await commands.isContactListEmpty();
|
const query = await commands.isContactListEmpty();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -153,9 +141,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
checkContact: async (pubkey: string) => {
|
||||||
static async checkContact(pubkey: string) {
|
|
||||||
const query = await commands.checkContact(pubkey);
|
const query = await commands.checkContact(pubkey);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -163,9 +150,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
toggleContact: async (pubkey: string, alias?: string) => {
|
||||||
static async toggleContact(pubkey: string, alias?: string) {
|
|
||||||
const query = await commands.toggleContact(pubkey, alias);
|
const query = await commands.toggleContact(pubkey, alias);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -173,9 +159,8 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
f2f: async (npub: string) => {
|
||||||
static async f2f(npub: string) {
|
|
||||||
const query = await commands.friendToFriend(npub);
|
const query = await commands.friendToFriend(npub);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -183,5 +168,5 @@ export class NostrAccount {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import { nip19 } from "nostr-tools";
|
|||||||
import { type Result, type RichEvent, commands } from "./commands";
|
import { type Result, type RichEvent, commands } from "./commands";
|
||||||
import { LumeEvent } from "./event";
|
import { LumeEvent } from "./event";
|
||||||
|
|
||||||
export class NostrQuery {
|
function toLumeEvents(richEvents: RichEvent[]) {
|
||||||
static #toLumeEvents(richEvents: RichEvent[]) {
|
|
||||||
const events = richEvents.map((item) => {
|
const events = richEvents.map((item) => {
|
||||||
const nostrEvent: NostrEvent = JSON.parse(item.raw);
|
const nostrEvent: NostrEvent = JSON.parse(item.raw);
|
||||||
|
|
||||||
@@ -25,9 +24,10 @@ export class NostrQuery {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async upload(filePath?: string) {
|
export const NostrQuery = {
|
||||||
|
upload: async (filePath?: string) => {
|
||||||
const allowExts = [
|
const allowExts = [
|
||||||
"png",
|
"png",
|
||||||
"jpeg",
|
"jpeg",
|
||||||
@@ -80,9 +80,8 @@ export class NostrQuery {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(String(e));
|
throw new Error(String(e));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getNotifications: async () => {
|
||||||
static async getNotifications() {
|
|
||||||
const query = await commands.getNotifications();
|
const query = await commands.getNotifications();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -94,9 +93,8 @@ export class NostrQuery {
|
|||||||
console.error(query.error);
|
console.error(query.error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getProfile: async (pubkey: string) => {
|
||||||
static async getProfile(pubkey: string) {
|
|
||||||
const normalize = pubkey.replace("nostr:", "").replace(/[^\w\s]/gi, "");
|
const normalize = pubkey.replace("nostr:", "").replace(/[^\w\s]/gi, "");
|
||||||
const query = await commands.getProfile(normalize);
|
const query = await commands.getProfile(normalize);
|
||||||
|
|
||||||
@@ -106,9 +104,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getEvent: async (id: string, hint?: string) => {
|
||||||
static async getEvent(id: string, hint?: string) {
|
|
||||||
// Validate ID
|
// Validate ID
|
||||||
const normalizeId: string = id
|
const normalizeId: string = id
|
||||||
.replace("nostr:", "")
|
.replace("nostr:", "")
|
||||||
@@ -150,9 +147,8 @@ export class NostrQuery {
|
|||||||
console.log("[getEvent]: ", query.error);
|
console.log("[getEvent]: ", query.error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getRepostEvent: async (event: LumeEvent) => {
|
||||||
static async getRepostEvent(event: LumeEvent) {
|
|
||||||
try {
|
try {
|
||||||
const embed: NostrEvent = JSON.parse(event.content);
|
const embed: NostrEvent = JSON.parse(event.content);
|
||||||
const query = await commands.getEventMeta(embed.content);
|
const query = await commands.getEventMeta(embed.content);
|
||||||
@@ -181,33 +177,30 @@ export class NostrQuery {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getUserEvents: async (pubkey: string, asOf?: number) => {
|
||||||
static async getUserEvents(pubkey: string, asOf?: number) {
|
|
||||||
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
||||||
const query = await commands.getEventsBy(pubkey, until);
|
const query = await commands.getEventsBy(pubkey, until);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
const data = NostrQuery.#toLumeEvents(query.data);
|
const data = toLumeEvents(query.data);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getLocalEvents: async (asOf?: number) => {
|
||||||
static async getLocalEvents(asOf?: number) {
|
|
||||||
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
||||||
const query = await commands.getLocalEvents(until);
|
const query = await commands.getLocalEvents(until);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
const data = NostrQuery.#toLumeEvents(query.data);
|
const data = toLumeEvents(query.data);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
listenLocalEvent: async () => {
|
||||||
static async listenLocalEvent() {
|
|
||||||
const label = getCurrent().label;
|
const label = getCurrent().label;
|
||||||
const query = await commands.listenLocalEvent(label);
|
const query = await commands.listenLocalEvent(label);
|
||||||
|
|
||||||
@@ -216,46 +209,42 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getGroupEvents: async (pubkeys: string[], asOf?: number) => {
|
||||||
static async getGroupEvents(pubkeys: string[], asOf?: number) {
|
|
||||||
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
||||||
const query = await commands.getGroupEvents(pubkeys, until);
|
const query = await commands.getGroupEvents(pubkeys, until);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
const data = NostrQuery.#toLumeEvents(query.data);
|
const data = toLumeEvents(query.data);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getGlobalEvents: async (asOf?: number) => {
|
||||||
static async getGlobalEvents(asOf?: number) {
|
|
||||||
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
||||||
const query = await commands.getGlobalEvents(until);
|
const query = await commands.getGlobalEvents(until);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
const data = NostrQuery.#toLumeEvents(query.data);
|
const data = toLumeEvents(query.data);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getHashtagEvents: async (hashtags: string[], asOf?: number) => {
|
||||||
static async getHashtagEvents(hashtags: string[], asOf?: number) {
|
|
||||||
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
const until: string = asOf && asOf > 0 ? asOf.toString() : undefined;
|
||||||
const nostrTags = hashtags.map((tag) => tag.replace("#", ""));
|
const nostrTags = hashtags.map((tag) => tag.replace("#", ""));
|
||||||
const query = await commands.getHashtagEvents(nostrTags, until);
|
const query = await commands.getHashtagEvents(nostrTags, until);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
const data = NostrQuery.#toLumeEvents(query.data);
|
const data = toLumeEvents(query.data);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
verifyNip05: async (pubkey: string, nip05?: string) => {
|
||||||
static async verifyNip05(pubkey: string, nip05?: string) {
|
|
||||||
const query = await commands.verifyNip05(pubkey, nip05);
|
const query = await commands.verifyNip05(pubkey, nip05);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -263,9 +252,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getNstore: async (key: string) => {
|
||||||
static async getNstore(key: string) {
|
|
||||||
const query = await commands.getNstore(key);
|
const query = await commands.getNstore(key);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -274,9 +262,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
setNstore: async (key: string, value: string) => {
|
||||||
static async setNstore(key: string, value: string) {
|
|
||||||
const query = await commands.setNstore(key, value);
|
const query = await commands.setNstore(key, value);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -284,9 +271,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getUserSettings: async () => {
|
||||||
static async getUserSettings() {
|
|
||||||
const query = await commands.getSettings();
|
const query = await commands.getSettings();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -294,9 +280,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
return query.error;
|
return query.error;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
setUserSettings: async (newSettings: string) => {
|
||||||
static async setUserSettings(newSettings: string) {
|
|
||||||
const query = await commands.setNewSettings(newSettings);
|
const query = await commands.setNewSettings(newSettings);
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -304,9 +289,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
return query.error;
|
return query.error;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getColumns: async () => {
|
||||||
static async getColumns() {
|
|
||||||
const key = "lume:columns";
|
const key = "lume:columns";
|
||||||
const systemPath = "resources/system_columns.json";
|
const systemPath = "resources/system_columns.json";
|
||||||
const resourcePath = await resolveResource(systemPath);
|
const resourcePath = await resolveResource(systemPath);
|
||||||
@@ -331,9 +315,8 @@ export class NostrQuery {
|
|||||||
} catch {
|
} catch {
|
||||||
return systemColumns;
|
return systemColumns;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
setColumns: async (columns: LumeColumn[]) => {
|
||||||
static async setColumns(columns: LumeColumn[]) {
|
|
||||||
const key = "lume:columns";
|
const key = "lume:columns";
|
||||||
const content = JSON.stringify(columns);
|
const content = JSON.stringify(columns);
|
||||||
const query = await commands.setNstore(key, content);
|
const query = await commands.setNstore(key, content);
|
||||||
@@ -343,9 +326,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getRelays: async () => {
|
||||||
static async getRelays() {
|
|
||||||
const query = await commands.getRelays();
|
const query = await commands.getRelays();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -353,9 +335,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
connectRelay: async (url: string) => {
|
||||||
static async connectRelay(url: string) {
|
|
||||||
const relayUrl = new URL(url);
|
const relayUrl = new URL(url);
|
||||||
|
|
||||||
if (relayUrl.protocol === "wss:" || relayUrl.protocol === "ws:") {
|
if (relayUrl.protocol === "wss:" || relayUrl.protocol === "ws:") {
|
||||||
@@ -367,9 +348,8 @@ export class NostrQuery {
|
|||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
removeRelay: async (url: string) => {
|
||||||
static async removeRelay(url: string) {
|
|
||||||
const relayUrl = new URL(url);
|
const relayUrl = new URL(url);
|
||||||
|
|
||||||
if (relayUrl.protocol === "wss:" || relayUrl.protocol === "ws:") {
|
if (relayUrl.protocol === "wss:" || relayUrl.protocol === "ws:") {
|
||||||
@@ -381,9 +361,8 @@ export class NostrQuery {
|
|||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getBootstrapRelays: async () => {
|
||||||
static async getBootstrapRelays() {
|
|
||||||
const query = await commands.getBootstrapRelays();
|
const query = await commands.getBootstrapRelays();
|
||||||
|
|
||||||
if (query.status === "ok") {
|
if (query.status === "ok") {
|
||||||
@@ -401,9 +380,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
saveBootstrapRelays: async (relays: Relay[]) => {
|
||||||
static async saveBootstrapRelays(relays: Relay[]) {
|
|
||||||
const text = relays
|
const text = relays
|
||||||
.map((relay) => Object.values(relay).join(","))
|
.map((relay) => Object.values(relay).join(","))
|
||||||
.join("\n");
|
.join("\n");
|
||||||
@@ -414,9 +392,8 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
unlisten: async (id?: string) => {
|
||||||
static async unlisten(id?: string) {
|
|
||||||
const label = id ? id : getCurrent().label;
|
const label = id ? id : getCurrent().label;
|
||||||
const query = await commands.unlisten(label);
|
const query = await commands.unlisten(label);
|
||||||
|
|
||||||
@@ -425,5 +402,5 @@ export class NostrQuery {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ import type { NostrEvent } from "@lume/types";
|
|||||||
import { commands } from "./commands";
|
import { commands } from "./commands";
|
||||||
import type { LumeEvent } from "./event";
|
import type { LumeEvent } from "./event";
|
||||||
|
|
||||||
export class LumeWindow {
|
export const LumeWindow = {
|
||||||
static async openMainWindow() {
|
openMainWindow: async () => {
|
||||||
const query = await commands.openMainWindow();
|
const query = await commands.openMainWindow();
|
||||||
return query;
|
return query;
|
||||||
}
|
},
|
||||||
|
openEvent: async (event: NostrEvent | LumeEvent) => {
|
||||||
static async openEvent(event: NostrEvent | LumeEvent) {
|
|
||||||
const eTags = event.tags.filter((tag) => tag[0] === "e" || tag[0] === "q");
|
const eTags = event.tags.filter((tag) => tag[0] === "e" || tag[0] === "q");
|
||||||
const root: string =
|
const root: string =
|
||||||
eTags.find((el) => el[3] === "root")?.[1] ?? eTags[0]?.[1];
|
eTags.find((el) => el[3] === "root")?.[1] ?? eTags[0]?.[1];
|
||||||
@@ -34,9 +33,8 @@ export class LumeWindow {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
openProfile: async (pubkey: string) => {
|
||||||
static async openProfile(pubkey: string) {
|
|
||||||
const label = `user-${pubkey}`;
|
const label = `user-${pubkey}`;
|
||||||
const query = await commands.openWindow({
|
const query = await commands.openWindow({
|
||||||
label,
|
label,
|
||||||
@@ -54,9 +52,8 @@ export class LumeWindow {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
openEditor: async (reply_to?: string, quote?: string) => {
|
||||||
static async openEditor(reply_to?: string, quote?: string) {
|
|
||||||
let url: string;
|
let url: string;
|
||||||
|
|
||||||
if (reply_to) {
|
if (reply_to) {
|
||||||
@@ -88,9 +85,8 @@ export class LumeWindow {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
openZap: async (id: string) => {
|
||||||
static async openZap(id: string) {
|
|
||||||
const wallet = await commands.loadWallet();
|
const wallet = await commands.loadWallet();
|
||||||
|
|
||||||
if (wallet.status === "ok") {
|
if (wallet.status === "ok") {
|
||||||
@@ -107,9 +103,8 @@ export class LumeWindow {
|
|||||||
} else {
|
} else {
|
||||||
await LumeWindow.openSettings("bitcoin-connect");
|
await LumeWindow.openSettings("bitcoin-connect");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
openSettings: async (path?: string) => {
|
||||||
static async openSettings(path?: string) {
|
|
||||||
const label = "settings";
|
const label = "settings";
|
||||||
const query = await commands.openWindow({
|
const query = await commands.openWindow({
|
||||||
label,
|
label,
|
||||||
@@ -127,9 +122,8 @@ export class LumeWindow {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
openSearch: async (searchType: "notes" | "users", searchQuery: string) => {
|
||||||
static async openSearch(searchType: "notes" | "users", searchQuery: string) {
|
|
||||||
const url = `/search/${searchType}?query=${searchQuery}`;
|
const url = `/search/${searchType}?query=${searchQuery}`;
|
||||||
const label = `search-${searchQuery
|
const label = `search-${searchQuery
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
@@ -153,5 +147,5 @@ export class LumeWindow {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(query.error);
|
throw new Error(query.error);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
"titleBarStyle": "Overlay",
|
"titleBarStyle": "Overlay",
|
||||||
"width": 1045,
|
"width": 1045,
|
||||||
"height": 800,
|
"height": 800,
|
||||||
"minWidth": 500,
|
"minWidth": 480,
|
||||||
"minHeight": 800,
|
"minHeight": 760,
|
||||||
"hiddenTitle": true,
|
"hiddenTitle": true,
|
||||||
"windowEffects": {
|
"windowEffects": {
|
||||||
"state": "followsWindowActiveState",
|
"state": "followsWindowActiveState",
|
||||||
|
|||||||
Reference in New Issue
Block a user