diff --git a/lib/screens/user_screen.dart b/lib/screens/user_screen.dart index da4b10a..3dc6b2e 100644 --- a/lib/screens/user_screen.dart +++ b/lib/screens/user_screen.dart @@ -226,8 +226,6 @@ class _UserZapsList extends HookConsumerWidget { query( tags: allAppTags, source: const LocalAndRemoteSource(relays: 'social'), - and: (zap) => {zap.zapRequest}, - andSource: const LocalAndRemoteSource(relays: 'social', stream: false), subscriptionPrefix: 'user-app-zaps', ), ); @@ -237,8 +235,6 @@ class _UserZapsList extends HookConsumerWidget { query( tags: {'#e': metadataIds}, source: const LocalAndRemoteSource(relays: 'social'), - and: (zap) => {zap.zapRequest}, - andSource: const LocalAndRemoteSource(relays: 'social', stream: false), subscriptionPrefix: 'user-metadata-zaps', ), ); @@ -250,13 +246,13 @@ class _UserZapsList extends HookConsumerWidget { return const SizedBox.shrink(); } - // Collect pubkeys from zaps and zapRequests for profile query + // Collect zapper pubkeys from metadata (already extracted from description tag) final zapperPubkeys = {}; for (final zap in allZaps) { - zapperPubkeys.add(zap.event.pubkey); - final zapRequest = zap.zapRequest.value; - if (zapRequest != null) { - zapperPubkeys.add(zapRequest.event.pubkey); + // The zapper's pubkey is in event.metadata['author'], extracted from description + final zapperPubkey = zap.event.metadata['author'] as String?; + if (zapperPubkey != null) { + zapperPubkeys.add(zapperPubkey); } } diff --git a/lib/widgets/app_detail_widgets.dart b/lib/widgets/app_detail_widgets.dart index d4859b4..4ab9542 100644 --- a/lib/widgets/app_detail_widgets.dart +++ b/lib/widgets/app_detail_widgets.dart @@ -296,34 +296,61 @@ class _ZappersListSectionWithMetadata extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + // Query zaps on app (via #a tag) final zapsState = ref.watch( query( tags: app.event.addressableIdTagMap, - source: LocalAndRemoteSource(relays: 'social'), - and: (zap) => {zap.author}, - andSource: LocalAndRemoteSource(relays: 'social', stream: false), + source: const LocalAndRemoteSource(relays: 'social'), subscriptionPrefix: 'app-zaps', ), ); + // Query zaps on metadata (via #e tag) final zapsOnMetadataState = ref.watch( query( tags: { '#e': {metadataId}, }, - and: (zap) => {zap.author}, - source: LocalAndRemoteSource(relays: 'social'), - andSource: LocalAndRemoteSource(relays: 'social', stream: false), + source: const LocalAndRemoteSource(relays: 'social'), subscriptionPrefix: 'metadata-zaps', ), ); - final zaps = {...zapsState.models, ...zapsOnMetadataState.models}; - if (zaps.isEmpty) return const SizedBox.shrink(); + // Combine zaps from both queries + final allZaps = {...zapsState.models, ...zapsOnMetadataState.models}; + + if (allZaps.isEmpty) return const SizedBox.shrink(); + + // Collect zapper pubkeys from metadata (already extracted from description tag) + final zapperPubkeys = {}; + for (final zap in allZaps) { + // The zapper's pubkey is in event.metadata['author'], extracted from description + final zapperPubkey = zap.event.metadata['author'] as String?; + if (zapperPubkey != null) { + zapperPubkeys.add(zapperPubkey); + } + } + + // Query profiles separately with cachedFor + final profilesState = ref.watch( + query( + authors: zapperPubkeys, + source: const LocalAndRemoteSource( + relays: {'social', 'vertex'}, + cachedFor: Duration(hours: 2), + ), + ), + ); + final profilesMap = { + for (final p in profilesState.models) p.pubkey: p, + }; return Padding( padding: const EdgeInsets.only(top: 8), - child: ZappersHorizontalList(zaps: zaps.toList()), + child: ZappersHorizontalList( + zaps: allZaps.toList(), + profilesMap: profilesMap, + ), ); } } diff --git a/lib/widgets/app_stack_container.dart b/lib/widgets/app_stack_container.dart index b924171..ee53a2e 100644 --- a/lib/widgets/app_stack_container.dart +++ b/lib/widgets/app_stack_container.dart @@ -229,22 +229,12 @@ class _SkeletonStackCard extends StatelessWidget { ), ), const SizedBox(height: 12), - Row( - children: List.generate( - 3, - (index) => Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 2), - child: AspectRatio( - aspectRatio: 1, - child: Container( - decoration: BoxDecoration( - color: AppColors.darkSkeletonBase, - borderRadius: BorderRadius.circular(8), - ), - ), - ), - ), + AspectRatio( + aspectRatio: 4, + child: Container( + decoration: BoxDecoration( + color: AppColors.darkSkeletonBase, + borderRadius: BorderRadius.circular(8), ), ), ), diff --git a/lib/widgets/zap_widgets.dart b/lib/widgets/zap_widgets.dart index 108fcdc..f57b125 100644 --- a/lib/widgets/zap_widgets.dart +++ b/lib/widgets/zap_widgets.dart @@ -90,31 +90,28 @@ class ZappersHorizontalList extends StatelessWidget { final theme = Theme.of(context); final color = theme.textTheme.bodySmall?.color?.withValues(alpha: 0.8); - // Group sats per zapper (prefer zapRequest author over wallet author) + // Group sats per zapper using metadata['author'] (extracted from description tag) final Map satsPerPubkey = {}; final Map profileByPubkey = {}; for (final zap in zaps) { - // Get pubkeys - prefer zapRequest author over wallet author - final requestPubkey = zap.zapRequest.value?.event.pubkey; - final walletPubkey = zap.event.pubkey; - final chosenPubkey = requestPubkey ?? walletPubkey; + // The zapper's pubkey is in event.metadata['author'], extracted from description + final zapperPubkey = zap.event.metadata['author'] as String?; + if (zapperPubkey == null) continue; - // Get profile from provided map or fall back to relationship + // Get profile from provided map or fall back to author relationship Profile? chosenProfile; if (profilesMap != null) { - chosenProfile = profilesMap![chosenPubkey]; + chosenProfile = profilesMap![zapperPubkey]; } else { - // Legacy: try to get from relationship - final requestAuthor = zap.zapRequest.value?.author.value; - final walletAuthor = zap.author.value; - chosenProfile = requestAuthor ?? walletAuthor; + // Legacy: try to get from author relationship (which now points to zapper) + chosenProfile = zap.author.value; } - satsPerPubkey[chosenPubkey] = - (satsPerPubkey[chosenPubkey] ?? 0) + zap.amount; + satsPerPubkey[zapperPubkey] = + (satsPerPubkey[zapperPubkey] ?? 0) + zap.amount; if (chosenProfile != null) { - profileByPubkey[chosenPubkey] = chosenProfile; + profileByPubkey[zapperPubkey] = chosenProfile; } }