From 02bf5e7dd5cc79e4496f8a7eca2daabeee08ca97 Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Thu, 30 Jul 2020 15:24:14 -0400 Subject: [PATCH] account: cleanup Do not update account settings on start, it could cause app freezing when receive notification at the same time. Change-Id: Ib5859f47dc3ca0fe52b406ced9a3cf3780ae33d1 --- Ring/Ring/AppDelegate.swift | 8 +------ Ring/Ring/Services/AccountsService.swift | 27 +----------------------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/Ring/Ring/AppDelegate.swift b/Ring/Ring/AppDelegate.swift index d9c2d4705..9a529c39b 100644 --- a/Ring/Ring/AppDelegate.swift +++ b/Ring/Ring/AppDelegate.swift @@ -168,9 +168,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD .subscribe(onCompleted: { //set selected account if exists self.appCoordinator.start() - for account in self.accountService.accounts { - self.accountService.setDetails(forAccountId: account.id) - } if self.accountService.hasAccountWithProxyEnabled() { self.registerVoipNotifications() } else { @@ -239,7 +236,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func prepareVideoAcceleration() { // we want enable hardware acceleration by default so if key does not exists, - // means it was not disabled by user + // means it was not disabled by user let keyExists = UserDefaults.standard.object(forKey: hardareAccelerationKey) != nil let enable = keyExists ? UserDefaults.standard.bool(forKey: hardareAccelerationKey) : true self.videoService.setHardwareAccelerated(withState: enable) @@ -296,7 +293,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD private func unregisterVoipNotifications() { self.voipRegistry.desiredPushTypes = nil - self.accountService.savePushToken(token: "") self.accountService.setPushNotificationToken(token: "") } @@ -436,7 +432,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD extension AppDelegate: PKPushRegistryDelegate { func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) { - self.accountService.savePushToken(token: "") self.accountService.setPushNotificationToken(token: "") } @@ -455,7 +450,6 @@ extension AppDelegate: PKPushRegistryDelegate { func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { if type == PKPushType.voIP { let deviceTokenString = pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined() - self.accountService.savePushToken(token: deviceTokenString) self.accountService.setPushNotificationToken(token: deviceTokenString) } } diff --git a/Ring/Ring/Services/AccountsService.swift b/Ring/Ring/Services/AccountsService.swift index e5169c916..5769f4aa4 100644 --- a/Ring/Ring/Services/AccountsService.swift +++ b/Ring/Ring/Services/AccountsService.swift @@ -522,24 +522,6 @@ class AccountsService: AccountAdapterDelegate { return result } - func setDetails(forAccountId accountId: String) { - let details = self.getAccountDetails(fromAccountId: accountId) - let filename = "" - if details - .get(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.ringtonePath)) == filename && - details - .get(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.ringtoneEnabled)) == "false" { - return - } - details - .set(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.ringtonePath), - withValue: filename) - details - .set(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.ringtoneEnabled), - withValue: "false") - setAccountDetails(forAccountId: accountId, withDetails: details) - } - /** Gets an account from the list of accounts handled by the application. @@ -696,6 +678,7 @@ class AccountsService: AccountAdapterDelegate { accountDetails!.updateValue("true", forKey: ConfigKey.videoEnabled.rawValue) accountDetails!.updateValue(accountType, forKey: ConfigKey.accountType.rawValue) accountDetails!.updateValue("true", forKey: ConfigKey.accountUpnpEnabled.rawValue) + accountDetails!.updateValue("false", forKey: ConfigKey.ringtoneEnabled.rawValue) return accountDetails! } @@ -892,14 +875,6 @@ class AccountsService: AccountAdapterDelegate { return proxyEnabled } - func savePushToken(token: String) { - for account in accounts { - let accountDetails = self.getAccountDetails(fromAccountId: account.id) - accountDetails.set(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.devicePushToken), withValue: token) - self.setAccountDetails(forAccountId: account.id, withDetails: accountDetails) - } - } - func proxyEnabled(accountID: String) -> Variable<Bool> { let variable = Variable<Bool>(getCurrentProxyState(accountID: accountID)) self.sharedResponseStream -- GitLab