Skip to content

Refactor subscription & request management#9

Merged
barrydeen merged 1 commit intomainfrom
feature/subscription-management-refactor
Feb 19, 2026
Merged

Refactor subscription & request management#9
barrydeen merged 1 commit intomainfrom
feature/subscription-management-refactor

Conversation

@barrydeen
Copy link
Copy Markdown
Owner

Summary

  • Message queuing: Relay now queues messages (cap 50) when disconnected and drains on reconnection, preventing silently dropped messages during reconnect windows
  • Smarter reconnection: Replaced Thread.sleep with coroutine delay in Relay, added awaitAnyConnected() to RelayPool replacing hardcoded delay(2000) in onAppResume()
  • Combined engagement subs: Merged separate reaction/zap/reply-count subscriptions into single per-chunk engagement subscription (~14 subs → ~2 per feed load)
  • Unified quote resolution: All quote fetching routes through one batched queue with cross-event dedup, 300ms debounce with flush-at-20 threshold, and failed fetch tracking to prevent infinite retries
  • Per-relay subscription tracking: New SubscriptionTracker enforces soft cap of 10 subs per relay (priority subs like feed/dms/notif bypass), integrated into all RelayPool send methods

Test plan

  • Launch app → feed loads → reactions, zaps, and reply counts appear on notes
  • Background app for 30s → foreground → feed refreshes without "0 relays connected"
  • Scroll feed → quoted notes render (both q-tag and nostr: URI quotes)
  • Check Relays screen: subscription count per relay stays under 10
  • Monitor logcat for RelayPool tags: no "Cooldown" entries from 429 rate limiting

…iting

- Add message queuing in Relay (ConcurrentLinkedQueue, cap 50) so messages sent during reconnect windows are delivered on reconnection instead of silently dropped
- Replace Thread.sleep in Relay.reconnect() with coroutine delay via injected CoroutineScope
- Add RelayPool.awaitAnyConnected() and replace hardcoded delay(2000) in onAppResume() for adaptive reconnection timing
- Combine separate reaction (kind 7), zap (kind 9735), and reply count (kind 1) subscriptions into single per-chunk engagement subscription, reducing ~14 subs to ~2 per feed load
- Unify quote resolution: fetchQuotedEvents() now routes through requestQuotedEvent() for cross-event dedup, increased debounce to 300ms with flush threshold of 20, and failedQuoteFetches set prevents infinite retries
- Add SubscriptionTracker with per-relay soft cap of 10 subs (priority subs bypass), integrated into RelayPool send methods
@barrydeen barrydeen merged commit 70ce01a into main Feb 19, 2026
@barrydeen barrydeen deleted the feature/subscription-management-refactor branch March 4, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant