Browse Source

Complete profile fetching implementation

- Add profileStats reactive state to track total fetched profiles and display limit
- Pass profileStats through EventNetwork -> Settings -> EventTypeConfig
- Update EventTypeConfig UI to show 'X of Y fetched' format for kind 0 profiles
- Profile fetching now extracts all pubkeys from loaded events first
- Display limit for profiles controls visualization, not fetching

This completes Phase 4 of the event types panel redesign.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
master
limina1 9 months ago
parent
commit
a0e2827e71
  1. 6
      src/lib/components/EventTypeConfig.svelte
  2. 4
      src/lib/navigator/EventNetwork/Settings.svelte
  3. 5
      src/lib/navigator/EventNetwork/index.svelte
  4. 20
      src/routes/visualize/+page.svelte

6
src/lib/components/EventTypeConfig.svelte

@ -71,6 +71,10 @@ @@ -71,6 +71,10 @@
const limit = parseInt(value);
if (!isNaN(limit) && limit > 0) {
visualizationConfig.updateEventLimit(kind, limit);
// Update profile stats display limit if it's kind 0
if (kind === 0) {
profileStats = { ...profileStats, displayLimit: limit };
}
}
}
@ -128,7 +132,7 @@ @@ -128,7 +132,7 @@
{#if config.kind === 0}
<input
type="number"
value={profileStats.displayLimit}
value={config.limit}
min="1"
max={profileStats.totalFetched || 1000}
class="w-16 px-2 py-1 text-xs border rounded dark:bg-gray-700 dark:border-gray-600 dark:text-white"

4
src/lib/navigator/EventNetwork/Settings.svelte

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
starVisualization = $bindable(true),
onFetchMissing = () => {},
eventCounts = {},
profileStats = { totalFetched: 0, displayLimit: 50 },
} = $props<{
count: number;
totalCount: number;
@ -25,6 +26,7 @@ @@ -25,6 +26,7 @@
starVisualization?: boolean;
onFetchMissing?: (ids: string[]) => void;
eventCounts?: { [kind: number]: number };
profileStats?: { totalFetched: number; displayLimit: number };
}>();
let expanded = $state(false);
@ -134,7 +136,7 @@ @@ -134,7 +136,7 @@
</Button>
</div>
{#if eventTypesExpanded}
<EventTypeConfig onReload={onupdate} {eventCounts} />
<EventTypeConfig onReload={onupdate} {eventCounts} {profileStats} />
{/if}
</div>

5
src/lib/navigator/EventNetwork/index.svelte

@ -74,7 +74,8 @@ @@ -74,7 +74,8 @@
onupdate,
onclear = () => {},
onTagExpansionChange,
onFetchMissing = () => {}
onFetchMissing = () => {},
profileStats = { totalFetched: 0, displayLimit: 50 }
} = $props<{
events?: NDKEvent[];
followListEvents?: NDKEvent[];
@ -83,6 +84,7 @@ @@ -83,6 +84,7 @@
onclear?: () => void;
onTagExpansionChange?: (depth: number, tags: string[]) => void;
onFetchMissing?: (ids: string[]) => void;
profileStats?: { totalFetched: number; displayLimit: number };
}>();
// Error state
@ -1215,6 +1217,7 @@ @@ -1215,6 +1217,7 @@
{onFetchMissing}
bind:starVisualization
{eventCounts}
{profileStats}
/>
<!-- svelte-ignore a11y_click_events_have_key_events -->

20
src/routes/visualize/+page.svelte

@ -57,6 +57,12 @@ @@ -57,6 +57,12 @@
? `Loading profiles: ${profileLoadingProgress.current}/${profileLoadingProgress.total}`
: null
);
// Profile stats for EventTypeConfig
let profileStats = $state<{totalFetched: number, displayLimit: number}>({
totalFetched: 0,
displayLimit: 50
});
/**
* Fetches follow lists (kind 3) with depth expansion
@ -528,14 +534,11 @@ @@ -528,14 +534,11 @@
profileLoadingProgress = null;
debug("Profile fetch complete");
// Store the total count for display
// The limit in kind0Config now controls display, not fetch
if (typeof window !== 'undefined' && window.profileStats) {
window.profileStats = {
totalFetched: allPubkeys.size,
displayLimit: kind0Config.limit
};
}
// Update profile stats for display
profileStats = {
totalFetched: allPubkeys.size,
displayLimit: kind0Config.limit
};
}
// Step 7: Apply display limits
@ -1022,6 +1025,7 @@ @@ -1022,6 +1025,7 @@
onclear={clearEvents}
onTagExpansionChange={handleTagExpansion}
onFetchMissing={fetchMissingEvents}
{profileStats}
/>
{/if}
</div>

Loading…
Cancel
Save