Fixed bug: stale transaction on delayed resend

This commit is contained in:
Michelle Linington 2021-08-04 21:22:22 -07:00
parent 0e8fe169a4
commit e95b0a8dba

View File

@ -99,16 +99,20 @@ extension OWSMessageManager {
transaction: writeTx
)
let sendBlock = {
let sendBlock = { (transaction: SDSAnyWriteTransaction) in
if let resendResponse = resendResponse {
Self.messageSenderJobQueue.add(message: resendResponse.asPreparer, transaction: writeTx)
Self.messageSenderJobQueue.add(message: resendResponse.asPreparer, transaction: transaction)
}
}
if DebugFlags.delayedMessageResend.get() {
DispatchQueue.sharedUtility.asyncAfter(deadline: .now() + 10, execute: sendBlock)
DispatchQueue.sharedUtility.asyncAfter(deadline: .now() + 10) {
Self.databaseStorage.asyncWrite { writeTx in
sendBlock(writeTx)
}
}
} else {
sendBlock()
sendBlock(writeTx)
}
} catch {