feat: add search window (NIP-50) (#181)
* feat: add search window * chore: improve search ui
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
"@radix-ui/react-hover-card": "^1.0.7",
|
||||
"@radix-ui/react-popover": "^1.0.7",
|
||||
"@radix-ui/react-tooltip": "^1.0.7",
|
||||
"@tanstack/react-query": "^5.29.2",
|
||||
"@tanstack/react-query": "^5.31.0",
|
||||
"@tanstack/react-router": "^1.29.2",
|
||||
"get-urls": "^12.1.0",
|
||||
"media-chrome": "^3.2.1",
|
||||
@@ -28,7 +28,7 @@
|
||||
"react-string-replace": "^1.1.1",
|
||||
"sonner": "^1.4.41",
|
||||
"string-strip-html": "^13.4.8",
|
||||
"virtua": "^0.30.1"
|
||||
"virtua": "^0.30.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lume/tailwindcss": "workspace:^",
|
||||
|
||||
@@ -139,6 +139,22 @@ export class Ark {
|
||||
}
|
||||
}
|
||||
|
||||
public async search(content: string, limit: number) {
|
||||
try {
|
||||
if (content.length < 1) return [];
|
||||
|
||||
const events: Event[] = await invoke("search", {
|
||||
content: content.trim(),
|
||||
limit,
|
||||
});
|
||||
|
||||
return events;
|
||||
} catch (e) {
|
||||
console.info(String(e));
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public async get_events(
|
||||
limit: number,
|
||||
asOf?: number,
|
||||
@@ -722,7 +738,6 @@ export class Ark {
|
||||
minHeight: 800,
|
||||
width: 500,
|
||||
height: 800,
|
||||
hiddenTitle: true,
|
||||
titleBarStyle: "overlay",
|
||||
center: false,
|
||||
});
|
||||
@@ -742,7 +757,6 @@ export class Ark {
|
||||
minHeight: 800,
|
||||
width: 500,
|
||||
height: 800,
|
||||
hiddenTitle: true,
|
||||
titleBarStyle: "overlay",
|
||||
});
|
||||
|
||||
@@ -807,7 +821,6 @@ export class Ark {
|
||||
minHeight: 500,
|
||||
width: 400,
|
||||
height: 500,
|
||||
hiddenTitle: true,
|
||||
titleBarStyle: "overlay",
|
||||
});
|
||||
|
||||
@@ -826,7 +839,24 @@ export class Ark {
|
||||
minHeight: 500,
|
||||
width: 800,
|
||||
height: 500,
|
||||
hiddenTitle: true,
|
||||
titleBarStyle: "overlay",
|
||||
});
|
||||
|
||||
this.windows.push(window);
|
||||
} catch (e) {
|
||||
throw new Error(String(e));
|
||||
}
|
||||
}
|
||||
|
||||
public open_search() {
|
||||
try {
|
||||
const window = new WebviewWindow("search", {
|
||||
title: "Search",
|
||||
url: "/search",
|
||||
width: 750,
|
||||
height: 470,
|
||||
minimizable: false,
|
||||
resizable: false,
|
||||
titleBarStyle: "overlay",
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user