diff --git a/apps/desktop2/src/routes/__root.tsx b/apps/desktop2/src/routes/__root.tsx index df559792..cdb2ddcb 100644 --- a/apps/desktop2/src/routes/__root.tsx +++ b/apps/desktop2/src/routes/__root.tsx @@ -1,18 +1,11 @@ import { CheckCircleIcon, InfoCircleIcon, CancelCircleIcon } from "@lume/icons"; -import type { Interests, Metadata, Settings } from "@lume/types"; +import type { Settings } from "@lume/types"; import { Spinner } from "@lume/ui"; import type { QueryClient } from "@tanstack/react-query"; import { Outlet, createRootRouteWithContext } from "@tanstack/react-router"; import type { Platform } from "@tauri-apps/plugin-os"; -import type { Descendant } from "slate"; import { Toaster } from "sonner"; -type EditorElement = { - type: string; - children: Descendant[]; - eventId?: string; -}; - interface RouterContext { // System queryClient: QueryClient; @@ -21,13 +14,8 @@ interface RouterContext { locale?: string; // Settings settings?: Settings; - interests?: Interests; - // Profile + // Accounts accounts?: string[]; - profile?: Metadata; - isNewUser?: boolean; - // Editor - initialValue?: EditorElement[]; } export const Route = createRootRouteWithContext()({ diff --git a/apps/desktop2/src/routes/editor/-components/media.tsx b/apps/desktop2/src/routes/editor/-components/media.tsx index 6ed58ce8..9c46a121 100644 --- a/apps/desktop2/src/routes/editor/-components/media.tsx +++ b/apps/desktop2/src/routes/editor/-components/media.tsx @@ -13,7 +13,7 @@ export function MediaButton({ className }: { className?: string }) { const editor = useSlateStatic(); const [loading, setLoading] = useState(false); - const uploadToNostrBuild = async () => { + const upload = async () => { try { // start loading setLoading(true); @@ -66,7 +66,7 @@ export function MediaButton({ className }: { className?: string }) { -
- {reply_to && !quote ? ( +
+ {search.reply_to ? (
- +
) : null} -
+
} placeholder={ - reply_to ? "Type your reply..." : t("editor.placeholder") + search.reply_to ? "Type your reply..." : t("editor.placeholder") } className="focus:outline-none" /> @@ -252,35 +242,24 @@ const withImages = (editor: ReactEditor) => { return editor; }; -const Image = ({ attributes, children, element }) => { +const Image = ({ attributes, element, children }) => { const editor = useSlateStatic(); - const path = ReactEditor.findPath(editor as ReactEditor, element); - const selected = useSelected(); const focused = useFocused(); + const path = ReactEditor.findPath(editor as ReactEditor, element); return (
{children} -
- {element.url} - -
+ {element.url} Transforms.removeNodes(editor, { at: path })} + />
); }; diff --git a/packages/system/src/commands.ts b/packages/system/src/commands.ts index d3835aa5..6ecc71c8 100644 --- a/packages/system/src/commands.ts +++ b/packages/system/src/commands.ts @@ -1,420 +1,609 @@ - // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. - - export const commands = { -async getRelays() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_relays") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async connectRelay(relay: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("connect_relay", { relay }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async removeRelay(relay: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("remove_relay", { relay }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getAccounts() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_accounts") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async createAccount() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("create_account") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async saveAccount(nsec: string, password: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("save_account", { nsec, password }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getEncryptedKey(npub: string, password: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_encrypted_key", { npub, password }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async nostrConnect(npub: string, uri: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("nostr_connect", { npub, uri }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async loadAccount(npub: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("load_account", { npub }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async eventToBech32(id: string, relays: string[]) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("event_to_bech32", { id, relays }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async userToBech32(key: string, relays: string[]) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("user_to_bech32", { key, relays }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async toNpub(hex: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("to_npub", { hex }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async verifyNip05(key: string, nip05: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("verify_nip05", { key, nip05 }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async runNotification(accounts: string[]) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("run_notification", { accounts }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getActivities(account: string, kind: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_activities", { account, kind }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getCurrentUserProfile() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_current_user_profile") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getProfile(id: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_profile", { id }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getContactList() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_contact_list") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async setContactList(pubkeys: string[]) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("set_contact_list", { pubkeys }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async createProfile(name: string, displayName: string, about: string, picture: string, banner: string, nip05: string, lud16: string, website: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("create_profile", { name, displayName, about, picture, banner, nip05, lud16, website }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async follow(id: string, alias: string | null) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("follow", { id, alias }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async unfollow(id: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("unfollow", { id }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getNstore(key: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_nstore", { key }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async setNstore(key: string, content: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("set_nstore", { key, content }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async setNwc(uri: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("set_nwc", { uri }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async loadNwc() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("load_nwc") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getBalance() : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_balance") }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async zapProfile(id: string, amount: string, message: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("zap_profile", { id, amount, message }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async zapEvent(id: string, amount: string, message: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("zap_event", { id, amount, message }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async friendToFriend(npub: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("friend_to_friend", { npub }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getEvent(id: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_event", { id }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getReplies(id: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_replies", { id }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getEventsBy(publicKey: string, asOf: string | null) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_events_by", { publicKey, asOf }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getLocalEvents(pubkeys: string[], until: string | null) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_local_events", { pubkeys, until }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getGlobalEvents(until: string | null) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_global_events", { until }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async getHashtagEvents(hashtags: string[], until: string | null) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("get_hashtag_events", { hashtags, until }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async publish(content: string, tags: string[][]) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("publish", { content, tags }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async repost(raw: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("repost", { raw }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async showInFolder(path: string) : Promise { -await TAURI_INVOKE("show_in_folder", { path }); -}, -async createColumn(label: string, x: number, y: number, width: number, height: number, url: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("create_column", { label, x, y, width, height, url }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async closeColumn(label: string) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("close_column", { label }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async repositionColumn(label: string, x: number, y: number) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("reposition_column", { label, x, y }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async resizeColumn(label: string, width: number, height: number) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("resize_column", { label, width, height }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async openWindow(label: string, title: string, url: string, width: number, height: number) : Promise> { -try { - return { status: "ok", data: await TAURI_INVOKE("open_window", { label, title, url, width, height }) }; -} catch (e) { - if(e instanceof Error) throw e; - else return { status: "error", error: e as any }; -} -}, -async setBadge(count: number) : Promise { -await TAURI_INVOKE("set_badge", { count }); -} -} - +// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. +export const commands = { + async getRelays(): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_relays") }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async connectRelay(relay: string): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("connect_relay", { relay }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async removeRelay(relay: string): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("remove_relay", { relay }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getAccounts(): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_accounts") }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async createAccount(): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("create_account") }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async saveAccount( + nsec: string, + password: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("save_account", { nsec, password }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getEncryptedKey( + npub: string, + password: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_encrypted_key", { npub, password }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async nostrConnect( + npub: string, + uri: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("nostr_connect", { npub, uri }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async loadAccount(npub: string): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("load_account", { npub }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async eventToBech32( + id: string, + relays: string[], + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("event_to_bech32", { id, relays }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async userToBech32( + key: string, + relays: string[], + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("user_to_bech32", { key, relays }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async toNpub(hex: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("to_npub", { hex }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async verifyNip05( + key: string, + nip05: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("verify_nip05", { key, nip05 }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async runNotification(accounts: string[]): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("run_notification", { accounts }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getActivities( + account: string, + kind: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_activities", { account, kind }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getCurrentUserProfile(): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_current_user_profile"), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getProfile(id: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_profile", { id }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getContactList(): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_contact_list") }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async setContactList(pubkeys: string[]): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("set_contact_list", { pubkeys }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async createProfile( + name: string, + displayName: string, + about: string, + picture: string, + banner: string, + nip05: string, + lud16: string, + website: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("create_profile", { + name, + displayName, + about, + picture, + banner, + nip05, + lud16, + website, + }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async follow( + id: string, + alias: string | null, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("follow", { id, alias }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async unfollow(id: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("unfollow", { id }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getNstore(key: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_nstore", { key }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async setNstore( + key: string, + content: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("set_nstore", { key, content }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async setNwc(uri: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("set_nwc", { uri }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async loadNwc(): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("load_nwc") }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getBalance(): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_balance") }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async zapProfile( + id: string, + amount: string, + message: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("zap_profile", { id, amount, message }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async zapEvent( + id: string, + amount: string, + message: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("zap_event", { id, amount, message }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async friendToFriend(npub: string): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("friend_to_friend", { npub }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getEvent(id: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_event", { id }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getReplies(id: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("get_replies", { id }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getEventsBy( + publicKey: string, + asOf: string | null, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_events_by", { publicKey, asOf }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getLocalEvents( + pubkeys: string[], + until: string | null, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_local_events", { pubkeys, until }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getGlobalEvents( + until: string | null, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_global_events", { until }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async getHashtagEvents( + hashtags: string[], + until: string | null, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("get_hashtag_events", { hashtags, until }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async publish( + content: string, + tags: string[][], + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("publish", { content, tags }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async repost(raw: string): Promise> { + try { + return { status: "ok", data: await TAURI_INVOKE("repost", { raw }) }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async showInFolder(path: string): Promise { + await TAURI_INVOKE("show_in_folder", { path }); + }, + async createColumn( + label: string, + x: number, + y: number, + width: number, + height: number, + url: string, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("create_column", { + label, + x, + y, + width, + height, + url, + }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async closeColumn(label: string): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("close_column", { label }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async repositionColumn( + label: string, + x: number, + y: number, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("reposition_column", { label, x, y }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async resizeColumn( + label: string, + width: number, + height: number, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("resize_column", { label, width, height }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async openWindow( + label: string, + title: string, + url: string, + width: number, + height: number, + ): Promise> { + try { + return { + status: "ok", + data: await TAURI_INVOKE("open_window", { + label, + title, + url, + width, + height, + }), + }; + } catch (e) { + if (e instanceof Error) throw e; + else return { status: "error", error: e as any }; + } + }, + async setBadge(count: number): Promise { + await TAURI_INVOKE("set_badge", { count }); + }, +}; /** user-defined types **/ -export type Account = { npub: string; nsec: string } -export type Relays = { connected: string[]; read: string[] | null; write: string[] | null; both: string[] | null } +export type Account = { npub: string; nsec: string }; +export type Relays = { + connected: string[]; + read: string[] | null; + write: string[] | null; + both: string[] | null; +}; /** tauri-specta globals **/ - import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; +import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core"; import * as TAURI_API_EVENT from "@tauri-apps/api/event"; import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; type __EventObj__ = { - listen: ( - cb: TAURI_API_EVENT.EventCallback - ) => ReturnType>; - once: ( - cb: TAURI_API_EVENT.EventCallback - ) => ReturnType>; - emit: T extends null - ? (payload?: T) => ReturnType - : (payload: T) => ReturnType; + listen: ( + cb: TAURI_API_EVENT.EventCallback, + ) => ReturnType>; + once: ( + cb: TAURI_API_EVENT.EventCallback, + ) => ReturnType>; + emit: T extends null + ? (payload?: T) => ReturnType + : (payload: T) => ReturnType; }; export type Result = - | { status: "ok"; data: T } - | { status: "error"; error: E }; + | { status: "ok"; data: T } + | { status: "error"; error: E }; function __makeEvents__>( - mappings: Record + mappings: Record, ) { - return new Proxy( - {} as unknown as { - [K in keyof T]: __EventObj__ & { - (handle: __WebviewWindow__): __EventObj__; - }; - }, - { - get: (_, event) => { - const name = mappings[event as keyof T]; + return new Proxy( + {} as unknown as { + [K in keyof T]: __EventObj__ & { + (handle: __WebviewWindow__): __EventObj__; + }; + }, + { + get: (_, event) => { + const name = mappings[event as keyof T]; - return new Proxy((() => {}) as any, { - apply: (_, __, [window]: [__WebviewWindow__]) => ({ - listen: (arg: any) => window.listen(name, arg), - once: (arg: any) => window.once(name, arg), - emit: (arg: any) => window.emit(name, arg), - }), - get: (_, command: keyof __EventObj__) => { - switch (command) { - case "listen": - return (arg: any) => TAURI_API_EVENT.listen(name, arg); - case "once": - return (arg: any) => TAURI_API_EVENT.once(name, arg); - case "emit": - return (arg: any) => TAURI_API_EVENT.emit(name, arg); - } - }, - }); - }, - } - ); + return new Proxy((() => {}) as any, { + apply: (_, __, [window]: [__WebviewWindow__]) => ({ + listen: (arg: any) => window.listen(name, arg), + once: (arg: any) => window.once(name, arg), + emit: (arg: any) => window.emit(name, arg), + }), + get: (_, command: keyof __EventObj__) => { + switch (command) { + case "listen": + return (arg: any) => TAURI_API_EVENT.listen(name, arg); + case "once": + return (arg: any) => TAURI_API_EVENT.once(name, arg); + case "emit": + return (arg: any) => TAURI_API_EVENT.emit(name, arg); + } + }, + }); + }, + }, + ); } - - \ No newline at end of file diff --git a/packages/utils/src/editor.ts b/packages/utils/src/editor.ts index 586cf64d..2428121c 100644 --- a/packages/utils/src/editor.ts +++ b/packages/utils/src/editor.ts @@ -60,17 +60,10 @@ export const insertMention = ( name: contact.profile.name || contact.profile.display_name || "anon", children: [text], }; - const extraText = [ - { - type: "paragraph", - children: [text], - }, - ]; // @ts-ignore, idk ReactEditor.focus(editor); Transforms.insertNodes(editor, mention); - Transforms.insertNodes(editor, extraText); }; export const insertNostrEvent = (