pull/472/head
Niels Andriesse 4 years ago
parent ca862096b4
commit 9d605c03f0

@ -8,7 +8,12 @@ enum Onboarding {
func preregister(with seed: Data, ed25519KeyPair: Sign.KeyPair, x25519KeyPair: ECKeyPair) {
let userDefaults = UserDefaults.standard
KeyPairUtilities.store(seed: seed, ed25519KeyPair: ed25519KeyPair, x25519KeyPair: x25519KeyPair)
TSAccountManager.sharedInstance().phoneNumberAwaitingVerification = x25519KeyPair.hexEncodedPublicKey
let x25519PublicKey = x25519KeyPair.hexEncodedPublicKey
TSAccountManager.sharedInstance().phoneNumberAwaitingVerification = x25519PublicKey
Storage.writeSync { transaction in
let user = Contact(sessionID: x25519PublicKey)
Storage.shared.setContact(user, using: transaction)
}
switch self {
case .register:
userDefaults[.hasViewedSeed] = false

@ -25,12 +25,18 @@ extension Storage {
transaction.setObject(contact, forKey: contact.sessionID, inCollection: Storage.contactCollection)
transaction.addCompletionQueue(DispatchQueue.main) {
// Delete old profile picture if needed
if let oldProfilePictureFileName = oldContact?.profilePictureFileName {
if let oldProfilePictureFileName = oldContact?.profilePictureFileName,
oldProfilePictureFileName != contact.profilePictureFileName {
let path = OWSUserProfile.profileAvatarFilepath(withFilename: oldProfilePictureFileName)
DispatchQueue.global(qos: .default).async {
OWSFileSystem.deleteFileIfExists(path)
}
}
// Download new profile picture if needed
if contact.profilePictureURL != nil && contact.profilePictureURL != oldContact?.profilePictureURL {
let profileManager = SSKEnvironment.shared.profileManager
profileManager.downloadAvatar(forUserProfile: contact)
}
// Post notification
let notificationCenter = NotificationCenter.default
notificationCenter.post(name: .contactUpdated, object: contact.sessionID)

Loading…
Cancel
Save