mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
5bb3bd7bc1
Updated the migrations so they can specify whether a configuration sync is required Moved the config sync logic into a MessageSender extension (makes far more sense than AppDelegate) Fixed a bug where the ShareVC was triggering the 'versionMigrationsDidComplete' twice Removed a couple of imports for files that had been deleted
33 lines
1.1 KiB
Swift
33 lines
1.1 KiB
Swift
|
|
@objc(SNContactsMigration)
|
|
public class ContactsMigration : OWSDatabaseMigration {
|
|
|
|
@objc
|
|
class func migrationId() -> String {
|
|
return "001"
|
|
}
|
|
|
|
override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) {
|
|
self.doMigrationAsync(completion: completion)
|
|
}
|
|
|
|
private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) {
|
|
var contacts: [Contact] = []
|
|
TSContactThread.enumerateCollectionObjects { object, _ in
|
|
guard let thread = object as? TSContactThread else { return }
|
|
let sessionID = thread.contactSessionID()
|
|
if let contact = Storage.shared.getContact(with: sessionID) {
|
|
contact.isTrusted = true
|
|
contacts.append(contact)
|
|
}
|
|
}
|
|
Storage.write(with: { transaction in
|
|
contacts.forEach { contact in
|
|
Storage.shared.setContact(contact, using: transaction)
|
|
}
|
|
self.save(with: transaction) // Intentionally capture self
|
|
}, completion: {
|
|
completion(true, false)
|
|
})
|
|
}
|
|
}
|