From d8b87db784ac4fb2f5bde2a8a975fde34069a9e1 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Thu, 5 Jun 2025 10:16:05 -0700 Subject: [PATCH] Flesh out recent activity component --- CLAUDE.md | 71 +------ src/app/components/Content.svelte | 2 +- src/app/components/SpaceRecentActivity.svelte | 187 +++++++++--------- 3 files changed, 102 insertions(+), 158 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 682c0d22..f9017159 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,28 +6,6 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co Flotilla is a Discord-like Nostr client that operates on the concept of "relays as groups/spaces." Built with SvelteKit 2.5 and Svelte 5, it provides messaging, threads, calendar events, and social features across Nostr relays. -## Development Commands - -```bash -# Development -pnpm run dev # Start dev server on port 1847 -pnpm run check # TypeScript checking -pnpm run check:watch # Watch mode TypeScript checking - -# Production -pnpm run build # Custom build with env processing -./build.sh # Main build script with PWA assets -pnpm run sourcemaps # Build with sourcemap upload - -# Code Quality -pnpm run lint # ESLint + Prettier checking -pnpm run format # Auto-format with Prettier - -# Mobile -pnpm run release:android # Android APK build -npx cap sync # Sync web assets to native -``` - ## Architecture ### Core Technology Stack @@ -37,58 +15,18 @@ npx cap sync # Sync web assets to native - **Capacitor 7** - Cross-platform mobile deployment - **TypeScript** - Full type safety throughout -### Key Directories -- `/src/app/state.ts` - Global state management, stores, derived values -- `/src/app/components/` - 80+ feature-specific Svelte components -- `/src/lib/components/` - Shared/generic UI components -- `/src/routes/` - SvelteKit file-based routing with dynamic relay/room routes -- `/src/app/commands.ts` - User actions and business logic -- `/src/assets/icons/` - 60+ custom SVG icons - ### State Management Patterns - Svelte stores with Welshman reactive patterns - Repository pattern for Nostr event storage with 10k event limit - Derived stores for computed values and real-time updates - Event-based architecture with reactive data flow -### Nostr Integration Architecture -- **NIP-29 support** - Group chat functionality via relays -- **NIP-46 support** - Remote signing (Nostr Connect/Bunker) -- **Event unwrapping** - Handles gift-wrapped messages for privacy -- **Real-time relay management** - Automatic connection and authentication -- **Web of trust calculations** - User reputation and content filtering - -### Mobile & PWA Features -- Responsive navigation (drawer on mobile, sidebar on desktop) -- Capacitor integration for native mobile apps -- PWA with offline support and auto-updating -- Safe area handling for iOS/Android - -## Environment Configuration - -All environment variables are optional and enable platform customization: - -```bash -# Branding -VITE_PLATFORM_NAME="Custom Name" -VITE_PLATFORM_LOGO="/custom-logo.png" -VITE_PLATFORM_DESCRIPTION="Custom description" - -# Platform Mode (single-relay instance) -VITE_PLATFORM_RELAYS="wss://relay.example.com" - -# Bootstrap and Discovery -VITE_DEFAULT_PUBKEYS="npub1...,npub2..." # Web of trust seed -VITE_INDEXER_RELAYS="wss://indexer1.com,wss://indexer2.com" - -# Monitoring -VITE_GLITCHTIP_API_KEY="..." # Error reporting -``` - -The `build.sh` script processes these variables and generates theme files. - ## Important Patterns +### Finding Code +- Prefer navigating from one file to the next following imports when possible +- If search is necessary, use `ack`, not `grep` or `rg`. + ### Component Organization - Components are organized by feature (Chat, Calendar, Profile, Space) - Use existing components from `/lib/components/` before creating new ones @@ -103,6 +41,7 @@ The `build.sh` script processes these variables and generates theme files. - Events flow through the repository pattern in `state.ts` - Use Welshman utilities for event validation and parsing - Handle both plain and gift-wrapped events for privacy +- Prefer seconds to milliseconds when handling nostr events. ### Styling Conventions - TailwindCSS with DaisyUI components diff --git a/src/app/components/Content.svelte b/src/app/components/Content.svelte index 776d6ddd..ec947b03 100644 --- a/src/app/components/Content.svelte +++ b/src/app/components/Content.svelte @@ -130,7 +130,7 @@ {:else}
{#each shortContent as parsed, i} {#if isNewline(parsed) && !isBlock(i - 1)} diff --git a/src/app/components/SpaceRecentActivity.svelte b/src/app/components/SpaceRecentActivity.svelte index 14b2d0c5..c0b7473c 100644 --- a/src/app/components/SpaceRecentActivity.svelte +++ b/src/app/components/SpaceRecentActivity.svelte @@ -1,70 +1,70 @@
@@ -74,53 +74,58 @@ Recent Conversations
- {#each mockConversations as conversation (conversation.id)} -
-
-
- -
-
- #{conversation.room} - - {formatTimestamp(conversation.starter.timestamp)} -
-
-

{conversation.starter.content}

+ {#if $conversations.length === 0} +
+

No recent conversations

+
+ {:else} + {#each $conversations.slice(0, limit) as { room, events, latest, earliest, participants } (latest.id)} +
+
+
+ +
+
+ #{room} + + {formatTimestamp(earliest.created_at)} +
+
-
-
-
- - - {conversation.replyCount} replies +
+
+ + + {events.length} messages + +
+ +
+
+ + {formatTimestamp(latest.created_at)} -
- -
- - {formatTimestamp(conversation.lastActivity)} - -
- {#if conversation.latestReply}
- + Latest reply:
-

- {conversation.latestReply.content} -

+
- {/if} +
-
- {/each} - + {/each} + {#if $conversations.length > limit} + + {/if} + {/if}