Refactor MessageRouter to use generic Transport abstraction

- Decouple MessageRouter from specific Mesh/Nostr implementations
- Update NostrTransport to implement isPeerReachable using a local cache of favorited peers
- Update ChatViewModel to inject transports as a list
- Mark NostrTransport as @unchecked Sendable to handle internal thread safety
This commit is contained in:
jack
2025-11-26 18:39:35 -10:00
parent 9e57bce5c3
commit 37c2b3a8c2
3 changed files with 84 additions and 62 deletions
+2 -1
View File
@@ -436,7 +436,8 @@ final class ChatViewModel: ObservableObject, BitchatDelegate, CommandContextProv
self.privateChatManager = PrivateChatManager(meshService: meshService)
self.unifiedPeerService = UnifiedPeerService(meshService: meshService, idBridge: idBridge, identityManager: identityManager)
let nostrTransport = NostrTransport(keychain: keychain, idBridge: idBridge)
self.messageRouter = MessageRouter(mesh: meshService, nostr: nostrTransport)
nostrTransport.senderPeerID = meshService.myPeerID
self.messageRouter = MessageRouter(transports: [meshService, nostrTransport])
// Route receipts from PrivateChatManager through MessageRouter
self.privateChatManager.messageRouter = self.messageRouter
// Allow PrivateChatManager to look up peer info for message consolidation