clean up and improve perf
This commit is contained in:
@@ -265,7 +265,7 @@ export function useNostr() {
|
||||
|
||||
if (!customSince) {
|
||||
if (dbEventsEmpty || db.account.last_login_at === 0) {
|
||||
since = db.account.network.length > 400 ? nHoursAgo(12) : nHoursAgo(24);
|
||||
since = db.account.network.length > 500 ? nHoursAgo(12) : nHoursAgo(24);
|
||||
} else {
|
||||
since = db.account.last_login_at;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ import { NDKUserProfile } from '@nostr-dev-kit/ndk';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useNDK } from '@libs/ndk/provider';
|
||||
import { useStorage } from '@libs/storage/provider';
|
||||
|
||||
export function useProfile(pubkey: string, embed?: string) {
|
||||
const { db } = useStorage();
|
||||
const { ndk } = useNDK();
|
||||
const {
|
||||
status,
|
||||
@@ -21,13 +19,7 @@ export function useProfile(pubkey: string, embed?: string) {
|
||||
|
||||
const cleanPubkey = pubkey.replace('-', '');
|
||||
const user = ndk.getUser({ hexpubkey: cleanPubkey });
|
||||
|
||||
const profile = await user.fetchProfile({ closeOnEose: true });
|
||||
if (!user.profile) return Promise.reject(new Error('profile not found'));
|
||||
|
||||
await db.createProfile(cleanPubkey, profile);
|
||||
|
||||
return user.profile;
|
||||
return await user.fetchProfile();
|
||||
},
|
||||
{
|
||||
enabled: !!ndk,
|
||||
@@ -35,6 +27,7 @@ export function useProfile(pubkey: string, embed?: string) {
|
||||
refetchOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
retry: 2,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ function isURL(string: string) {
|
||||
}
|
||||
|
||||
export function parser(eventContent: string) {
|
||||
if (!eventContent) return '';
|
||||
|
||||
try {
|
||||
const content: RichContent = {
|
||||
parsed: null,
|
||||
|
||||
Reference in New Issue
Block a user