mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Change to make the 'getUser(using:)' method more consistent
This commit is contained in:
parent
7aa1221987
commit
6205e72eab
2 changed files with 9 additions and 13 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Contact>
|
||||
func getAllContacts(with transaction: YapDatabaseReadTransaction) -> Set<Contact>
|
||||
|
||||
|
|
Loading…
Reference in a new issue