Do KeyOperations on the global thread.

pull/14/head
Mikunj 6 years ago committed by Mikunj Varsani
parent 8fff98d94e
commit 141fa8e2cc

@ -35,23 +35,26 @@ public class RefreshPreKeysOperation: OWSOperation {
Logger.debug("skipping - not registered") Logger.debug("skipping - not registered")
return return
} }
guard self.primaryStorage.currentSignedPrekeyId() == nil else { // Loki: Doing this on the global queue because they do it at the bottom
Logger.debug("Already have a signed prekey set") DispatchQueue.global().async {
guard self.primaryStorage.currentSignedPrekeyId() == nil else {
Logger.debug("Already have a signed prekey set")
self.reportSuccess()
return
}
let signedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord()
signedPreKeyRecord.markAsAcceptedByService()
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
TSPreKeyManager.clearPreKeyUpdateFailureCount()
TSPreKeyManager.clearSignedPreKeyRecords()
Logger.debug("done")
self.reportSuccess() self.reportSuccess()
return
} }
let signedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord()
signedPreKeyRecord.markAsAcceptedByService()
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
TSPreKeyManager.clearPreKeyUpdateFailureCount()
TSPreKeyManager.clearSignedPreKeyRecords()
Logger.debug("done")
self.reportSuccess()
/* Loki: Original Code /* Loki: Original Code
* ============= * =============

@ -27,16 +27,19 @@ public class RotateSignedPreKeyOperation: OWSOperation {
return return
} }
let signedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord() // Loki: Doing this on the global queue because they do it at the bottom
signedPreKeyRecord.markAsAcceptedByService() DispatchQueue.global().async {
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord) let signedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord()
self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id) signedPreKeyRecord.markAsAcceptedByService()
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
TSPreKeyManager.clearPreKeyUpdateFailureCount() self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
TSPreKeyManager.clearSignedPreKeyRecords()
TSPreKeyManager.clearPreKeyUpdateFailureCount()
Logger.debug("done") TSPreKeyManager.clearSignedPreKeyRecords()
self.reportSuccess()
Logger.debug("done")
self.reportSuccess()
}
/* Loki: Original Code /* Loki: Original Code
* ========= * =========

Loading…
Cancel
Save