fix: overload
This commit is contained in:
@@ -32,10 +32,15 @@ export function Images({ urls }: { urls: string[] }) {
|
||||
return `https://wsrv.nl?url=${url}&ll&af&default=1&n=-1`;
|
||||
});
|
||||
} else {
|
||||
newUrls = urls.map(
|
||||
(url) =>
|
||||
`https://wsrv.nl?url=${url}&w=480&h=640&ll&af&default=1&n=-1`,
|
||||
);
|
||||
newUrls = urls.map((url) => {
|
||||
if (url.includes("_next/")) {
|
||||
return url;
|
||||
}
|
||||
if (url.includes("bsky.network")) {
|
||||
return url;
|
||||
}
|
||||
return `https://wsrv.nl?url=${url}&ll&af&default=1&n=-1`;
|
||||
});
|
||||
}
|
||||
|
||||
return newUrls;
|
||||
|
||||
@@ -42,11 +42,16 @@ function Screen() {
|
||||
const unlisten = getCurrentWindow().listen<string>(
|
||||
"metadata",
|
||||
async (data) => {
|
||||
const payload = data.payload;
|
||||
const event: NostrEvent = JSON.parse(payload);
|
||||
const event: NostrEvent = JSON.parse(data.payload);
|
||||
const metadata: Metadata = JSON.parse(event.content);
|
||||
|
||||
// Update query cache
|
||||
queryClient.setQueryData(["profile", event.pubkey], () => metadata);
|
||||
|
||||
// Reset query cache
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["profile", event.pubkey],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -29,25 +29,26 @@ export function useProfile(pubkey: string, data?: string) {
|
||||
const { isLoading, data: profile } = useQuery({
|
||||
queryKey: ["profile", hex],
|
||||
queryFn: async () => {
|
||||
if (data) {
|
||||
if (data?.length) {
|
||||
const metadata: Metadata = JSON.parse(data);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
const query = await commands.getProfile(hex);
|
||||
const res = await commands.getProfile(hex);
|
||||
|
||||
if (query.status === "ok") {
|
||||
const metadata: Metadata = JSON.parse(query.data);
|
||||
if (res.status === "ok") {
|
||||
const metadata: Metadata = JSON.parse(res.data);
|
||||
return metadata;
|
||||
} else {
|
||||
await getCurrentWindow().emit("request_metadata", { id: hex });
|
||||
return {};
|
||||
throw new Error(res.error);
|
||||
}
|
||||
},
|
||||
refetchOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
enabled: !!hex,
|
||||
retry: false,
|
||||
});
|
||||
|
||||
return { isLoading, profile };
|
||||
|
||||
Reference in New Issue
Block a user