Reverting change and fixing a force-cast crash

pull/604/head
Morgan Pretty 3 years ago
parent 6205e72eab
commit f8dfbd4244

@ -36,17 +36,21 @@ extension Storage {
} }
@objc public func getUser() -> Contact? { @objc public func getUser() -> Contact? {
return getUser(using: nil)
}
public func getUser(using transaction: YapDatabaseReadTransaction?) -> Contact? {
guard let userPublicKey = getUserPublicKey() else { return nil }
var result: Contact? var result: Contact?
if let transaction = transaction {
result = Storage.shared.getContact(with: userPublicKey, using: transaction)
}
else {
Storage.read { transaction in Storage.read { transaction in
result = self.getUser(using: transaction) result = Storage.shared.getContact(with: userPublicKey, using: transaction)
} }
return result
} }
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 getUserKeyPair() -> ECKeyPair?
func getUserED25519KeyPair() -> Box.KeyPair? func getUserED25519KeyPair() -> Box.KeyPair?
func getUser() -> Contact? func getUser() -> Contact?
func getUser(using transaction: Any) -> Contact? func getUser(using transaction: YapDatabaseReadTransaction?) -> Contact?
func getAllContacts() -> Set<Contact> func getAllContacts() -> Set<Contact>
func getAllContacts(with transaction: YapDatabaseReadTransaction) -> Set<Contact> func getAllContacts(with transaction: YapDatabaseReadTransaction) -> Set<Contact>

Loading…
Cancel
Save