Release v4.1 (#229)

* refactor: remove custom icon packs

* fix: command not work on windows

* fix: make open_window command async

* feat: improve commands

* feat: improve

* refactor: column

* feat: improve thread column

* feat: improve

* feat: add stories column

* feat: improve

* feat: add search column

* feat: add reset password

* feat: add subscription

* refactor: settings

* chore: improve commands

* fix: crash on production

* feat: use tauri store plugin for cache

* feat: new icon

* chore: update icon for windows

* chore: improve some columns

* chore: polish code
This commit is contained in:
雨宮蓮
2024-08-27 19:37:30 +07:00
committed by GitHub
parent 26ae473521
commit 61ad96ca63
318 changed files with 5564 additions and 8458 deletions
+23 -16
View File
@@ -1,7 +1,7 @@
import { commands } from "@/commands.gen";
import type { Metadata } from "@/types";
import { experimental_createPersister } from "@tanstack/query-persist-client-core";
import { useQuery } from "@tanstack/react-query";
import { nip19 } from "nostr-tools";
export function useProfile(pubkey: string, embed?: string) {
const {
@@ -11,30 +11,37 @@ export function useProfile(pubkey: string, embed?: string) {
} = useQuery({
queryKey: ["profile", pubkey],
queryFn: async () => {
try {
if (embed) return JSON.parse(embed) as Metadata;
if (embed) {
const metadata: Metadata = JSON.parse(embed);
return metadata;
}
const normalize = pubkey.replace("nostr:", "").replace(/[^\w\s]/gi, "");
const query = await commands.getProfile(normalize);
let normalizeId = pubkey.replace("nostr:", "").replace(/[^\w\s]/gi, "");
let relayHint: string;
if (query.status === "ok") {
return JSON.parse(query.data) as Metadata;
} else {
throw new Error(query.error);
if (normalizeId.startsWith("nprofile")) {
const decoded = nip19.decode(normalizeId);
if (decoded.type === "nprofile") {
relayHint = decoded.data.relays[0];
normalizeId = decoded.data.pubkey;
}
} catch (e) {
throw new Error(e);
}
console.log(relayHint);
const query = await commands.getProfile(normalizeId);
if (query.status === "ok") {
return JSON.parse(query.data) as Metadata;
} else {
throw new Error(query.error);
}
},
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
staleTime: Number.POSITIVE_INFINITY,
retry: 2,
persister: experimental_createPersister({
storage: localStorage,
maxAge: 1000 * 60 * 60 * 24, // 24 hours
}),
retry: false,
});
return { isLoading, isError, profile };