mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 18:25:21 +00:00
fix: unconditionally update mesh reference in MessageRouter.getInstance
This commit is contained in:
@@ -19,16 +19,10 @@ class MessageRouter private constructor(
|
|||||||
@Volatile private var INSTANCE: MessageRouter? = null
|
@Volatile private var INSTANCE: MessageRouter? = null
|
||||||
fun tryGetInstance(): MessageRouter? = INSTANCE
|
fun tryGetInstance(): MessageRouter? = INSTANCE
|
||||||
fun getInstance(context: Context, mesh: BluetoothMeshService): MessageRouter {
|
fun getInstance(context: Context, mesh: BluetoothMeshService): MessageRouter {
|
||||||
return INSTANCE ?: synchronized(this) {
|
val instance = INSTANCE ?: synchronized(this) {
|
||||||
|
INSTANCE ?: run {
|
||||||
val nostr = NostrTransport.getInstance(context)
|
val nostr = NostrTransport.getInstance(context)
|
||||||
INSTANCE?.also {
|
|
||||||
// Update mesh reference if needed and keep senderPeerID in sync
|
|
||||||
it.mesh = mesh
|
|
||||||
it.nostr.senderPeerID = mesh.myPeerID
|
|
||||||
return it
|
|
||||||
}
|
|
||||||
MessageRouter(context.applicationContext, mesh, nostr).also { instance ->
|
MessageRouter(context.applicationContext, mesh, nostr).also { instance ->
|
||||||
instance.nostr.senderPeerID = mesh.myPeerID
|
|
||||||
// Register for favorites changes to flush outbox
|
// Register for favorites changes to flush outbox
|
||||||
try {
|
try {
|
||||||
com.bitchat.android.favorites.FavoritesPersistenceService.shared.addListener(instance.favoriteListener)
|
com.bitchat.android.favorites.FavoritesPersistenceService.shared.addListener(instance.favoriteListener)
|
||||||
@@ -37,6 +31,11 @@ class MessageRouter private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Always update mesh reference and sync peer ID
|
||||||
|
instance.mesh = mesh
|
||||||
|
instance.nostr.senderPeerID = mesh.myPeerID
|
||||||
|
return instance
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outbox: peerID -> queued (content, nickname, messageID)
|
// Outbox: peerID -> queued (content, nickname, messageID)
|
||||||
|
|||||||
Reference in New Issue
Block a user