diff --git a/bitchat/Services/BLE/BLEService.swift b/bitchat/Services/BLE/BLEService.swift index 78df3254..50a170ff 100644 --- a/bitchat/Services/BLE/BLEService.swift +++ b/bitchat/Services/BLE/BLEService.swift @@ -521,8 +521,11 @@ final class BLEService: NSObject { } } - // Give leave message a moment to send - Thread.sleep(forTimeInterval: TransportConfig.bleThreadSleepWriteShortDelaySeconds) + // Give leave message a moment to send (cooperative delay allows BLE callbacks to fire) + let deadline = Date().addingTimeInterval(TransportConfig.bleThreadSleepWriteShortDelaySeconds) + while Date() < deadline { + RunLoop.current.run(until: Date().addingTimeInterval(0.01)) + } // Clear pending notifications collectionsQueue.sync(flags: .barrier) {