feat: add search window (NIP-50) (#181)

* feat: add search window
* chore: improve search ui
This commit is contained in:
雨宮蓮
2024-04-23 15:34:08 +07:00
committed by GitHub
parent c00a7749b4
commit 174a3cc74e
22 changed files with 507 additions and 236 deletions
+7 -1
View File
@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import { Metadata } from "@lume/types";
import { invoke } from "@tauri-apps/api/core";
export function useProfile(pubkey: string) {
export function useProfile(pubkey: string, embed?: string) {
const {
isLoading,
isError,
@@ -11,8 +11,14 @@ export function useProfile(pubkey: string) {
queryKey: ["user", pubkey],
queryFn: async () => {
try {
if (embed) {
const profile: Metadata = JSON.parse(embed);
return profile;
}
const id = pubkey.replace("nostr:", "").replace(/[^\w\s]/gi, "");
const cmd: Metadata = await invoke("get_profile", { id });
return cmd;
} catch (e) {
throw new Error(e);