Browse Source

Fix profile stats to show correct fetched count

- 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 <noreply@anthropic.com>
master
limina1 9 months ago
parent
commit
a5a89434dc
  1. 11
      src/lib/stores/visualizationConfig.ts
  2. 8
      src/routes/visualize/+page.svelte

11
src/lib/stores/visualizationConfig.ts

@ -13,7 +13,7 @@ export interface VisualizationConfig { @@ -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 { @@ -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() { @@ -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() { @@ -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() { @@ -162,7 +161,7 @@ function createVisualizationConfig() {
...config,
searchThroughFetched: !config.searchThroughFetched,
})),
toggleAppendMode: () =>
update((config) => ({
...config,

8
src/routes/visualize/+page.svelte

@ -21,7 +21,7 @@ @@ -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 @@ @@ -72,6 +72,7 @@
counts[event.kind] = (counts[event.kind] || 0) + 1;
}
});
debug("All event counts:", counts);
return counts;
});
@ -562,8 +563,9 @@ @@ -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 @@ @@ -854,7 +856,7 @@
// Update profile stats
profileStats = {
totalFetched: profileStats.totalFetched + newProfileEvents.length,
totalFetched: profileStats.totalFetched + newPubkeys.size,
displayLimit: profileStats.displayLimit
};
}

Loading…
Cancel
Save