Reverting change and fixing a force-cast crash

This commit is contained in:
Morgan Pretty 2022-03-24 14:23:47 +11:00
parent 6205e72eab
commit f8dfbd4244
2 changed files with 14 additions and 10 deletions

View File

@ -36,17 +36,21 @@ extension Storage {
}
@objc public func getUser() -> Contact? {
var result: Contact?
Storage.read { transaction in
result = self.getUser(using: transaction)
}
return result
return getUser(using: nil)
}
public func getUser(using transaction: Any) -> Contact? {
public func getUser(using transaction: YapDatabaseReadTransaction?) -> Contact? {
guard let userPublicKey = getUserPublicKey() else { return nil }
return Storage.shared.getContact(with: userPublicKey, using: transaction)
var result: Contact?
if let transaction = transaction {
result = Storage.shared.getContact(with: userPublicKey, using: transaction)
}
else {
Storage.read { transaction in
result = Storage.shared.getContact(with: userPublicKey, using: transaction)
}
}
return result
}
}

View File

@ -17,7 +17,7 @@ public protocol SessionMessagingKitStorageProtocol {
func getUserKeyPair() -> ECKeyPair?
func getUserED25519KeyPair() -> Box.KeyPair?
func getUser() -> Contact?
func getUser(using transaction: Any) -> Contact?
func getUser(using transaction: YapDatabaseReadTransaction?) -> Contact?
func getAllContacts() -> Set<Contact>
func getAllContacts(with transaction: YapDatabaseReadTransaction) -> Set<Contact>