From d206ff228ed105d0e7376ff7d17bb6017dc4a9fc Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 2 Nov 2025 21:06:40 +0100 Subject: [PATCH] fix: remove unnecessary label comparison and fix useEffect dependencies --- src/hooks/useProfileLabels.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/hooks/useProfileLabels.ts b/src/hooks/useProfileLabels.ts index 9d0ba13b..4868fdbb 100644 --- a/src/hooks/useProfileLabels.ts +++ b/src/hooks/useProfileLabels.ts @@ -166,11 +166,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null): // Update labels with what we found in localStorage cache and eventStore const initialResolveTime = Date.now() - startTime console.log(`[${ts()}] [npub-resolve] Initial resolution complete:`, labels.size, 'labels resolved in', initialResolveTime, 'ms. Will fetch', pubkeysToFetch.length, 'missing profiles.') - - // Only update if labels changed (avoid unnecessary re-renders) - if (labels.size !== profileLabels.size || Array.from(labels.keys()).some(k => labels.get(k) !== profileLabels.get(k))) { - setProfileLabels(new Map(labels)) - } + setProfileLabels(new Map(labels)) // Fetch missing profiles asynchronously if (pubkeysToFetch.length > 0 && relayPool && eventStore) { @@ -250,9 +246,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null): console.error(`[${ts()}] [npub-resolve] Error fetching profiles after`, fetchDuration, 'ms:', err) }) } - // eslint-disable-next-line react-hooks/exhaustive-deps - // initialLabels is derived from profileData, profileLabels is state we update (would cause loops) - }, [profileData, eventStore, relayPool]) + }, [profileData, eventStore, relayPool, initialLabels]) // Only log when size actually changes to reduce noise useEffect(() => {