Fix warnings and improve autocomplete positioning, add unit tests

- Remove unused variables (beforeCount, beforeFavCount)
- Remove Tx Power Level from advertising (not allowed)
- Fix autocomplete popup to appear near cursor position
- Calculate position based on nickname width and @ location
- Add comprehensive unit tests for:
  - Binary protocol encoding/decoding
  - Message padding for privacy
  - Bloom filter duplicate detection
  - BitchatMessage serialization
- Add test target to project.yml
This commit is contained in:
jack
2025-07-04 15:40:47 +02:00
parent e3cc469bf8
commit 986106fea4
7 changed files with 456 additions and 34 deletions
+1 -8
View File
@@ -407,9 +407,7 @@ class BluetoothMeshService: NSObject {
advertisementData = [
CBAdvertisementDataServiceUUIDsKey: [BluetoothMeshService.serviceUUID],
// Use only peer ID without any identifying prefix
CBAdvertisementDataLocalNameKey: myPeerID,
// Request max TX power for better range (system may adjust)
CBAdvertisementDataTxPowerLevelKey: NSNumber(value: 1)
CBAdvertisementDataLocalNameKey: myPeerID
]
isAdvertising = true
@@ -960,22 +958,17 @@ class BluetoothMeshService: NSObject {
if !messageIDsToRemove.isEmpty {
self.messageQueue.async(flags: .barrier) {
// Remove only the messages we sent to this specific peer
let beforeCount = self.messageCache.count
self.messageCache.removeAll { message in
messageIDsToRemove.contains(message.messageID)
}
let afterCount = self.messageCache.count
// Also remove from favorite queue if any
if var favoriteQueue = self.favoriteMessageQueue[peerID] {
let beforeFavCount = favoriteQueue.count
favoriteQueue.removeAll { message in
messageIDsToRemove.contains(message.messageID)
}
self.favoriteMessageQueue[peerID] = favoriteQueue.isEmpty ? nil : favoriteQueue
// Removed from favorite queue
}
// Removed from cache
}
}
}