Conversation
…iption re-sync Three targeted improvements to relay connection resilience and feed responsiveness: 1. ConnectivityFlow: wraps Android NetworkCallback as a Flow with 100ms debounce and distinctUntilChanged. FeedViewModel observes it to detect WiFi drops, cellular handoffs, and network restoration — triggering immediate relay reconnection instead of waiting for the next lifecycle event. 2. EventRepository: replace 250ms polling loop with Channel-based emission. Uses a conflated channel with 50ms settle window so concurrent relay inserts coalesce into a single StateFlow emission. ~5x faster perceived feed updates while still batching effectively. 3. RelayPool subscription re-sync: track active REQ messages per relay. When a relay reconnects (onOpen fires), automatically re-send all tracked subscriptions so data flows immediately. Previously a reconnected relay would sit idle until the next manual subscribe call.
…avHost Move relay lifecycle handling out of FeedViewModel and FeedScreen into a dedicated RelayLifecycleManager class: 1. RelayLifecycleManager: new class that owns connectivity observation (ConnectivityFlow) and app pause/resume logic. Takes an onReconnected callback so FeedViewModel can re-subscribe feeds without the manager knowing about feed internals. 2. Move lifecycle observer from FeedScreen to WispNavHost: the previous placement inside FeedScreen's DisposableEffect meant that pausing/ resuming the app while on Notifications, DMs, Search, or any other screen would not trigger relay reconnection. Now it fires on all screens. 3. Add onAppPause: previously there was no pause handler — health tracker sessions were only closed inside reconnectAll()/forceReconnectAll(). Now onAppPause explicitly closes sessions and marks the pool inactive. 4. FeedViewModel.onAppResume/onAppPause are thin delegates to the lifecycle manager, reducing god object surface area.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Network resilience improvements, faster feed updates, subscription re-sync on reconnect, lifecycle management refactor, and filter size chunking for large relay compatibility.
Changes
1. ConnectivityFlow — reactive network monitoring
ConnectivityFlowwraps Android'sConnectivityManager.NetworkCallbackas a Kotlin FlowConnectivityStatus.Active(networkId, isMobile)orConnectivityStatus.OffdistinctUntilChanged()prevents reconnection storms during WiFi↔cellular handoffs2. Faster feed updates (
EventRepository.kt)Channel(CONFLATED)-based approach3. Subscription re-sync on relay reconnect (
RelayPool.kt)activeSubscriptionsmap tracks last REQ message per sub ID per relayresyncSubscriptions()re-sends all tracked REQs4. RelayLifecycleManager extraction
RelayLifecycleManagerWispNavHost— fires on ALL screens5. Filter chunking for large author lists
sendChunkedToAll(){base},{base}:c1,{base}:c2closeOnAllRelays()discovers and closes all chunk variantssubscribeByAuthors,requestProfiles,requestMissingRelayListsTesting