mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fix device unlinking order of operations
This commit is contained in:
parent
c2de6f9f88
commit
164aeb4142
1 changed files with 11 additions and 4 deletions
|
@ -138,10 +138,17 @@ final class DeviceLinksVC : UIViewController, UITableViewDataSource, UITableView
|
|||
let linkedDeviceHexEncodedPublicKey = deviceLink.other.hexEncodedPublicKey
|
||||
guard let thread = TSContactThread.fetch(uniqueId: TSContactThread.threadId(fromContactId: linkedDeviceHexEncodedPublicKey)) else { return }
|
||||
let unlinkDeviceMessage = UnlinkDeviceMessage(thread: thread)!
|
||||
ThreadUtil.enqueue(unlinkDeviceMessage)
|
||||
let storage = OWSPrimaryStorage.shared()
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
storage.archiveAllSessions(forContact: linkedDeviceHexEncodedPublicKey, protocolContext: transaction)
|
||||
SSKEnvironment.shared.messageSender.send(unlinkDeviceMessage, success: {
|
||||
let storage = OWSPrimaryStorage.shared()
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
storage.deleteAllSessions(forContact: linkedDeviceHexEncodedPublicKey, protocolContext: transaction)
|
||||
}
|
||||
}) { _ in
|
||||
print("[Loki] Failed to send unlink device message.")
|
||||
let storage = OWSPrimaryStorage.shared()
|
||||
storage.dbReadWriteConnection.readWrite { transaction in
|
||||
storage.deleteAllSessions(forContact: linkedDeviceHexEncodedPublicKey, protocolContext: transaction)
|
||||
}
|
||||
}
|
||||
self?.updateDeviceLinks()
|
||||
}.catch { [weak self] _ in
|
||||
|
|
Loading…
Reference in a new issue