|
@@ -72,7 +72,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- openAccounts(dcAccounts)
|
|
|
|
|
|
+ let accountIds = dcAccounts.getAll()
|
|
|
|
+ for accountId in accountIds {
|
|
|
|
+ let dcContext = dcAccounts.get(id: accountId)
|
|
|
|
+ if !dcContext.isOpen() {
|
|
|
|
+ do {
|
|
|
|
+ let secret = try KeychainManager.getAccountSecret(accountID: accountId)
|
|
|
|
+ if !dcContext.open(passphrase: secret) {
|
|
|
|
+ logger.error("Failed to open database for account \(accountId)")
|
|
|
|
+ }
|
|
|
|
+ } catch KeychainError.unhandledError(let message, let status) {
|
|
|
|
+ logger.error("Keychain error. \(message). Error status: \(status)")
|
|
|
|
+ } catch {
|
|
|
|
+ logger.error("\(error)")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if dcAccounts.getAll().isEmpty, dcAccounts.add() == 0 {
|
|
if dcAccounts.getAll().isEmpty, dcAccounts.add() == 0 {
|
|
fatalError("Could not initialize a new account.")
|
|
fatalError("Could not initialize a new account.")
|
|
@@ -200,25 +215,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
logger.info("➡️ applicationProtectedDataWillBecomeUnavailable")
|
|
logger.info("➡️ applicationProtectedDataWillBecomeUnavailable")
|
|
}
|
|
}
|
|
|
|
|
|
- func openAccounts(_ dcAccounts: DcAccounts) {
|
|
|
|
- let accountIds = dcAccounts.getAll()
|
|
|
|
- for accountId in accountIds {
|
|
|
|
- let dcContext = dcAccounts.get(id: accountId)
|
|
|
|
- if !dcContext.isOpen() {
|
|
|
|
- do {
|
|
|
|
- let secret = try KeychainManager.getAccountSecret(accountID: accountId)
|
|
|
|
- if !dcContext.open(passphrase: secret) {
|
|
|
|
- logger.error("Failed to open database for account \(accountId)")
|
|
|
|
- }
|
|
|
|
- } catch KeychainError.unhandledError(let message, let status) {
|
|
|
|
- logger.error("Keychain error. \(message). Error status: \(status)")
|
|
|
|
- } catch {
|
|
|
|
- logger.error("\(error)")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
static func emitMsgsChangedIfShareExtensionWasUsed() {
|
|
static func emitMsgsChangedIfShareExtensionWasUsed() {
|
|
if let userDefaults = UserDefaults.shared, userDefaults.bool(forKey: UserDefaults.hasExtensionAttemptedToSend) {
|
|
if let userDefaults = UserDefaults.shared, userDefaults.bool(forKey: UserDefaults.hasExtensionAttemptedToSend) {
|
|
userDefaults.removeObject(forKey: UserDefaults.hasExtensionAttemptedToSend)
|
|
userDefaults.removeObject(forKey: UserDefaults.hasExtensionAttemptedToSend)
|
|
@@ -421,7 +417,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
logger.info("➡️ Notifications: didReceiveRemoteNotification \(userInfo)")
|
|
logger.info("➡️ Notifications: didReceiveRemoteNotification \(userInfo)")
|
|
increaseDebugCounter("notify-remote-receive")
|
|
increaseDebugCounter("notify-remote-receive")
|
|
pushToDebugArray("📡")
|
|
pushToDebugArray("📡")
|
|
- openAccounts(dcAccounts)
|
|
|
|
performFetch(completionHandler: completionHandler)
|
|
performFetch(completionHandler: completionHandler)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -438,7 +433,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|
logger.info("➡️ Notifications: performFetchWithCompletionHandler")
|
|
logger.info("➡️ Notifications: performFetchWithCompletionHandler")
|
|
increaseDebugCounter("notify-local-wakeup")
|
|
increaseDebugCounter("notify-local-wakeup")
|
|
pushToDebugArray("🏠")
|
|
pushToDebugArray("🏠")
|
|
- openAccounts(dcAccounts)
|
|
|
|
performFetch(completionHandler: completionHandler)
|
|
performFetch(completionHandler: completionHandler)
|
|
}
|
|
}
|
|
|
|
|