Browse Source

Add 'Show All' checkbox for content event kinds

Implements a checkbox option for kinds 30041 and 30818 that allows users to display all loaded content events instead of being limited by the number input.

Changes:
- Added showAll property to EventKindConfig interface
- Added toggleShowAllContent method to visualization store
- Updated EventTypeConfig UI to show "All" checkbox for content kinds
- Modified display filtering to respect showAll setting
- Disabled number input when showAll is checked

This improves the user experience by making it easy to show all content when working with publications and wiki pages.

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

Co-Authored-By: Claude <noreply@anthropic.com>
master
limina1 9 months ago
parent
commit
f3c74ebc9b
  1. 16
      src/lib/components/EventTypeConfig.svelte
  2. 10
      src/lib/stores/visualizationConfig.ts
  3. 11
      src/lib/utils/displayLimits.ts

16
src/lib/components/EventTypeConfig.svelte

@ -149,10 +149,24 @@ @@ -149,10 +149,24 @@
value={config.limit}
min="1"
max="1000"
class="w-16 px-2 py-1 text-xs border rounded dark:bg-gray-700 dark:border-gray-600 dark:text-white"
class="w-16 px-2 py-1 text-xs border rounded dark:bg-gray-700 dark:border-gray-600 dark:text-white {(config.kind === 30041 || config.kind === 30818) && config.showAll ? 'opacity-50' : ''}"
oninput={(e) => handleLimitChange(config.kind, e.currentTarget.value)}
title="Max to display"
disabled={(config.kind === 30041 || config.kind === 30818) && config.showAll}
/>
<!-- Show All checkbox for content kinds (30041, 30818) -->
{#if config.kind === 30041 || config.kind === 30818}
<label class="flex items-center gap-1 text-xs text-gray-600 dark:text-gray-400">
<input
type="checkbox"
checked={config.showAll || false}
onchange={() => visualizationConfig.toggleShowAllContent(config.kind)}
class="w-3 h-3"
/>
All
</label>
{/if}
{/if}
<!-- Nested levels for 30040 -->

10
src/lib/stores/visualizationConfig.ts

@ -5,6 +5,7 @@ export interface EventKindConfig { @@ -5,6 +5,7 @@ export interface EventKindConfig {
limit: number;
nestedLevels?: number; // Only for kind 30040
depth?: number; // Only for kind 3 (follow lists)
showAll?: boolean; // Only for content kinds (30041, 30818) - show all loaded content instead of limit
}
export interface VisualizationConfig {
@ -147,6 +148,15 @@ function createVisualizationConfig() { @@ -147,6 +148,15 @@ function createVisualizationConfig() {
),
})),
// Toggle showAll for content kinds (30041, 30818)
toggleShowAllContent: (kind: number) =>
update((config) => ({
...config,
eventConfigs: config.eventConfigs.map((ec) =>
ec.kind === kind ? { ...ec, showAll: !ec.showAll } : ec,
),
})),
// Get config for a specific kind
getEventConfig: (kind: number) => {
let config: EventKindConfig | undefined;

11
src/lib/utils/displayLimits.ts

@ -31,8 +31,15 @@ export function filterByDisplayLimits(events: NDKEvent[], limits: DisplayLimits, @@ -31,8 +31,15 @@ export function filterByDisplayLimits(events: NDKEvent[], limits: DisplayLimits,
const eventConfig = config?.eventConfigs.find(ec => ec.kind === kind);
const limit = eventConfig?.limit;
// If there's a limit configured for this kind, check it
if (limit !== undefined) {
// Special handling for content kinds (30041, 30818) with showAll option
if ((kind === 30041 || kind === 30818) && eventConfig?.showAll) {
// Show all content events when showAll is true
result.push(event);
// Still update the count for UI display
const currentCount = kindCounts.get(kind) || 0;
kindCounts.set(kind, currentCount + 1);
} else if (limit !== undefined) {
// Normal limit checking
const currentCount = kindCounts.get(kind) || 0;
if (currentCount < limit) {
result.push(event);

Loading…
Cancel
Save