diff --git a/SessionMessagingKit/Database/Storage+Shared.swift b/SessionMessagingKit/Database/Storage+Shared.swift index 0f3fdb8e4..d297aefb1 100644 --- a/SessionMessagingKit/Database/Storage+Shared.swift +++ b/SessionMessagingKit/Database/Storage+Shared.swift @@ -36,21 +36,17 @@ extension Storage { } @objc public func getUser() -> Contact? { - return getUser(using: nil) - } - - public func getUser(using transaction: Any?) -> Contact? { - guard let userPublicKey = getUserPublicKey() else { return nil } 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) - } + Storage.read { transaction in + result = self.getUser(using: transaction) } + return result } + + public func getUser(using transaction: Any) -> Contact? { + guard let userPublicKey = getUserPublicKey() else { return nil } + return Storage.shared.getContact(with: userPublicKey, using: transaction) + } } diff --git a/SessionMessagingKit/Storage.swift b/SessionMessagingKit/Storage.swift index 6bcabb3ae..ee5def11d 100644 --- a/SessionMessagingKit/Storage.swift +++ b/SessionMessagingKit/Storage.swift @@ -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: Any) -> Contact? func getAllContacts() -> Set func getAllContacts(with transaction: YapDatabaseReadTransaction) -> Set