Skip to content
Snippets Groups Projects
Commit 02bf5e7d authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

account: cleanup

Do not update account settings on start, it could cause
app freezing when receive notification at the same time.

Change-Id: Ib5859f47dc3ca0fe52b406ced9a3cf3780ae33d1
parent eb902258
Branches
Tags
No related merge requests found
......@@ -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 {
......@@ -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)
}
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment