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
32 lines
1.2 KiB
Swift
32 lines
1.2 KiB
Swift
import PromiseKit
|
|
import SessionMessagingKit
|
|
|
|
extension AppDelegate {
|
|
|
|
@objc(syncConfigurationIfNeeded)
|
|
func syncConfigurationIfNeeded() {
|
|
guard Storage.shared.getUser()?.name != nil else { return }
|
|
let userDefaults = UserDefaults.standard
|
|
let lastSync = userDefaults[.lastConfigurationSync] ?? .distantPast
|
|
guard Date().timeIntervalSince(lastSync) > 7 * 24 * 60 * 60 else { return } // Sync every 2 days
|
|
|
|
MessageSender.syncConfiguration(forceSyncNow: false)
|
|
.done {
|
|
// Only update the 'lastConfigurationSync' timestamp if we have done the first sync (Don't want
|
|
// a new device config sync to override config syncs from other devices)
|
|
if userDefaults[.hasSyncedInitialConfiguration] {
|
|
userDefaults[.lastConfigurationSync] = Date()
|
|
}
|
|
}
|
|
.retainUntilComplete()
|
|
}
|
|
|
|
@objc func startClosedGroupPoller() {
|
|
guard OWSIdentityManager.shared().identityKeyPair() != nil else { return }
|
|
ClosedGroupPoller.shared.start()
|
|
}
|
|
|
|
@objc func stopClosedGroupPoller() {
|
|
ClosedGroupPoller.shared.stop()
|
|
}
|
|
}
|