mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 01:45:20 +00:00
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:
@@ -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,43 +625,36 @@ 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 }
|
||||
|
||||
let publicKeyData = self.encryptionService.publicKey.rawRepresentation
|
||||
let packet = BitchatPacket(
|
||||
type: MessageType.keyExchange.rawValue,
|
||||
// Send key exchange and announce immediately without any delay
|
||||
let publicKeyData = self.encryptionService.publicKey.rawRepresentation
|
||||
let packet = BitchatPacket(
|
||||
type: MessageType.keyExchange.rawValue,
|
||||
senderID: self.myPeerID.data(using: .utf8)!,
|
||||
recipientID: nil,
|
||||
timestamp: UInt64(Date().timeIntervalSince1970),
|
||||
payload: try! JSONEncoder().encode(publicKeyData),
|
||||
signature: nil,
|
||||
ttl: 1
|
||||
)
|
||||
|
||||
if let data = packet.data {
|
||||
peripheral.writeValue(data, for: characteristic, type: .withResponse)
|
||||
}
|
||||
|
||||
// Send announce packet immediately after key exchange
|
||||
if let vm = self.delegate as? ChatViewModel {
|
||||
let announcePacket = BitchatPacket(
|
||||
type: MessageType.announce.rawValue,
|
||||
senderID: self.myPeerID.data(using: .utf8)!,
|
||||
recipientID: nil,
|
||||
timestamp: UInt64(Date().timeIntervalSince1970),
|
||||
payload: try! JSONEncoder().encode(publicKeyData),
|
||||
payload: vm.nickname.data(using: .utf8)!,
|
||||
signature: nil,
|
||||
ttl: 1
|
||||
)
|
||||
|
||||
if let data = packet.data {
|
||||
if let data = announcePacket.data {
|
||||
peripheral.writeValue(data, for: characteristic, type: .withResponse)
|
||||
}
|
||||
|
||||
// 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)!,
|
||||
recipientID: nil,
|
||||
timestamp: UInt64(Date().timeIntervalSince1970),
|
||||
payload: vm.nickname.data(using: .utf8)!,
|
||||
signature: nil,
|
||||
ttl: 1
|
||||
)
|
||||
if let data = announcePacket.data {
|
||||
peripheral.writeValue(data, for: characteristic, type: .withResponse)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]) {
|
||||
|
||||
@@ -106,14 +106,15 @@ struct ContentView: View {
|
||||
.opacity(0)
|
||||
} else {
|
||||
// Public chat header
|
||||
Text("bitchat")
|
||||
.font(.system(size: 18, weight: .medium, design: .monospaced))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Spacer()
|
||||
|
||||
// Peer status section
|
||||
peerStatusView
|
||||
HStack(spacing: 12) {
|
||||
Text("bitchat")
|
||||
.font(.system(size: 18, weight: .medium, design: .monospaced))
|
||||
.foregroundColor(textColor)
|
||||
|
||||
// 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 {
|
||||
|
||||
Reference in New Issue
Block a user