Fix peer dropdown layout and announcement timing

- Move peer dropdown next to bitchat title
- Add immediate peer announcement on connection
- Fix iOS menu chevron visibility with platform-specific styling
- Force UI updates for join/leave messages
- Add peers to active list immediately on connection
- Remove all announcement delays for instant name resolution
This commit is contained in:
jack
2025-07-02 21:39:31 +02:00
parent e50f14eeed
commit 1eaba703e9
3 changed files with 44 additions and 37 deletions
+4 -8
View File
@@ -559,6 +559,9 @@ extension BluetoothMeshService: CBCentralManagerDelegate {
connectedPeripherals[peerID] = peripheral
print("[DEBUG] Connected to peer: \(peerID)")
// Add to active peers immediately
activePeers.insert(peerID)
print("[DEBUG] Active peers: \(activePeers)")
// Update peer list to show we're connecting
@@ -622,10 +625,7 @@ extension BluetoothMeshService: CBPeripheralDelegate {
peripheral.setNotifyValue(true, for: characteristic)
peripheralCharacteristics[peripheral] = characteristic
// Send key exchange and announce immediately
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
// Send key exchange and announce immediately without any delay
let publicKeyData = self.encryptionService.publicKey.rawRepresentation
let packet = BitchatPacket(
type: MessageType.keyExchange.rawValue,
@@ -643,8 +643,6 @@ extension BluetoothMeshService: CBPeripheralDelegate {
// Send announce packet immediately after key exchange
if let vm = self.delegate as? ChatViewModel {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
let announcePacket = BitchatPacket(
type: MessageType.announce.rawValue,
senderID: self.myPeerID.data(using: .utf8)!,
@@ -661,8 +659,6 @@ extension BluetoothMeshService: CBPeripheralDelegate {
}
}
}
}
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
guard let data = characteristic.value,
+6
View File
@@ -252,6 +252,9 @@ extension ChatViewModel: BitchatDelegate {
)
messages.append(systemMessage)
print("[DEBUG] Added join message, total messages: \(messages.count)")
// Force UI update
objectWillChange.send()
}
func didDisconnectFromPeer(_ peerID: String) {
@@ -265,6 +268,9 @@ extension ChatViewModel: BitchatDelegate {
)
messages.append(systemMessage)
print("[DEBUG] Added leave message, total messages: \(messages.count)")
// Force UI update
objectWillChange.send()
}
func didUpdatePeerList(_ peers: [String]) {
+7 -2
View File
@@ -106,14 +106,15 @@ struct ContentView: View {
.opacity(0)
} else {
// Public chat header
HStack(spacing: 12) {
Text("bitchat")
.font(.system(size: 18, weight: .medium, design: .monospaced))
.foregroundColor(textColor)
Spacer()
// Peer status section
peerStatusView
.frame(maxWidth: 120)
}
Spacer()
@@ -188,7 +189,11 @@ struct ContentView: View {
}
}
}
#if os(macOS)
.menuStyle(.borderlessButton)
#else
.menuStyle(.automatic)
#endif
}
private var messagesView: some View {