Move the event parser and dedup functions to Rust (#206)
* feat: improve js parser * feat: move parser and dedup to rust * fix: parser * fix: get event function * feat: improve parser performance (#207) * feat: improve parser performance * feat: add test for video parsing * feat: finish new parser --------- Co-authored-by: XIAO YU <xyzmhx@gmail.com>
This commit is contained in:
@@ -1,18 +1,12 @@
|
||||
import type { Event, NostrEvent } from "@lume/types";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { NostrQuery } from "../query";
|
||||
|
||||
export function useEvent(id: string) {
|
||||
const { isLoading, isError, data } = useQuery({
|
||||
queryKey: ["event", id],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const eventId: string = id
|
||||
.replace("nostr:", "")
|
||||
.split("'")[0]
|
||||
.split(".")[0];
|
||||
const cmd: string = await invoke("get_event", { id: eventId });
|
||||
const event: NostrEvent = JSON.parse(cmd);
|
||||
const event = await NostrQuery.getEvent(id);
|
||||
return event;
|
||||
} catch (e) {
|
||||
throw new Error(e);
|
||||
|
||||
Reference in New Issue
Block a user