The Feed: TAMSIV's Most Complex Screen
Every app has that one screen that encapsulates all its complexity. For TAMSIV, it's the Feed. A single stream that blends everything: recent activity, notifications, gamification stats, badges.
Consolidated RPC
A single PostgreSQL function, get_consolidated_feed, aggregates tasks, memos, events, gamification, and group activity. A unified type with item_type for frontend routing.
Early versions: 3 seconds to load. After indexing and rewriting JOINs: 200ms.
React Native Rendering
Each item type has its component: FeedTaskItem, FeedMemoItem, FeedGamificationItem, FeedGroupItem. All within a FlatList from react-native-gesture-handler with getItemLayout.
The Problem of Expired Images
Supabase signed URLs expire after 60 minutes. Solution: store the storage_path and refresh URLs via StorageService.refreshAttachmentUrlsBatch(). Batch call rather than N individual calls.
Progressive Loading
Infinite pagination (20 items), pull-to-refresh, L1 memory cache + L2 AsyncStorage. The feed loads instantly from cache then updates in the background. This screen took me three weeks. It's also the one I'm most proud of.