From a5a89434dce281b5d681f4cfe04e904341494a19 Mon Sep 17 00:00:00 2001 From: limina1 Date: Tue, 17 Jun 2025 21:13:12 -0400 Subject: [PATCH] Fix profile stats to show correct fetched count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use total pubkeys size instead of newly fetched profile events length - This accounts for profiles that were already cached - Update both initial fetch and missing events fetch The issue was that when profiles were already cached, profileEvents.length was 0, making it look like no profiles were fetched even though they were available from cache. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/lib/stores/visualizationConfig.ts | 11 +++++------ src/routes/visualize/+page.svelte | 8 +++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/stores/visualizationConfig.ts b/src/lib/stores/visualizationConfig.ts index 1a49b1f..5d0b59b 100644 --- a/src/lib/stores/visualizationConfig.ts +++ b/src/lib/stores/visualizationConfig.ts @@ -13,7 +13,7 @@ export interface VisualizationConfig { // Graph traversal searchThroughFetched: boolean; - + // Append mode - add new events to existing graph instead of replacing appendMode?: boolean; @@ -27,7 +27,7 @@ export interface VisualizationConfig { // Default configurations for common event kinds const DEFAULT_EVENT_CONFIGS: EventKindConfig[] = [ - { kind: 0, limit: 50 }, // Metadata events (profiles) - controls how many profiles to display + { kind: 0, limit: 5 }, // Metadata events (profiles) - controls how many profiles to display { kind: 3, limit: 0, depth: 0 }, // Follow lists - limit 0 = don't fetch, >0 = fetch follow lists { kind: 30040, limit: 20, nestedLevels: 1 }, { kind: 30041, limit: 20 }, @@ -41,8 +41,8 @@ function createVisualizationConfig() { searchThroughFetched: true, appendMode: false, // Legacy properties - allowedKinds: DEFAULT_EVENT_CONFIGS.map(ec => ec.kind), - disabledKinds: [30041, 30818], + allowedKinds: DEFAULT_EVENT_CONFIGS.map((ec) => ec.kind), + disabledKinds: [30041, 30818], // Kind 0 not disabled so it shows as green when profiles are fetched allowFreeEvents: false, maxPublicationIndices: -1, maxEventsPerIndex: -1, @@ -147,7 +147,6 @@ function createVisualizationConfig() { ), })), - // Get config for a specific kind getEventConfig: (kind: number) => { let config: EventKindConfig | undefined; @@ -162,7 +161,7 @@ function createVisualizationConfig() { ...config, searchThroughFetched: !config.searchThroughFetched, })), - + toggleAppendMode: () => update((config) => ({ ...config, diff --git a/src/routes/visualize/+page.svelte b/src/routes/visualize/+page.svelte index 7ee9e7f..eb2c0fc 100644 --- a/src/routes/visualize/+page.svelte +++ b/src/routes/visualize/+page.svelte @@ -21,7 +21,7 @@ import { activePubkey } from "$lib/ndk"; // Configuration - const DEBUG = false; // Set to true to enable debug logging + const DEBUG = true; // Set to true to enable debug logging const INDEX_EVENT_KIND = 30040; const CONTENT_EVENT_KINDS = [30041, 30818]; @@ -72,6 +72,7 @@ counts[event.kind] = (counts[event.kind] || 0) + 1; } }); + debug("All event counts:", counts); return counts; }); @@ -562,8 +563,9 @@ allEvents = [...allEvents, ...profileEvents]; // Update profile stats for display + // Use the total number of pubkeys, not just newly fetched profiles profileStats = { - totalFetched: profileEvents.length, + totalFetched: allPubkeys.size, displayLimit: kind0Config.limit }; } @@ -854,7 +856,7 @@ // Update profile stats profileStats = { - totalFetched: profileStats.totalFetched + newProfileEvents.length, + totalFetched: profileStats.totalFetched + newPubkeys.size, displayLimit: profileStats.displayLimit }; }