Quick fix missing username bug

This commit is contained in:
Niels Andriesse 2021-03-05 13:06:35 +11:00
parent e170bfedf1
commit 76e5515610
1 changed files with 10 additions and 0 deletions

View File

@ -40,6 +40,16 @@ extension Storage {
var result: Contact?
Storage.read { transaction in
result = Storage.shared.getContact(with: userPublicKey)
// HACK: Apparently it's still possible for the user's contact info to be missing
if result == nil, let profile = OWSUserProfile.fetch(uniqueId: kLocalProfileUniqueId, transaction: transaction),
let userPublicKey = Storage.shared.getUserPublicKey() {
let user = Contact(sessionID: userPublicKey)
user.name = profile.profileName
user.profilePictureURL = profile.avatarUrlPath
user.profilePictureFileName = profile.avatarFileName
user.profilePictureEncryptionKey = profile.profileKey
result = user
}
}
return result
}