diff --git a/iOSClient/Account Settings/NCAccountSettingsModel.swift b/iOSClient/Account Settings/NCAccountSettingsModel.swift index 8eb33b49d8..ba7c01434f 100644 --- a/iOSClient/Account Settings/NCAccountSettingsModel.swift +++ b/iOSClient/Account Settings/NCAccountSettingsModel.swift @@ -160,7 +160,13 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling { } /// Function to change account after 1.5 sec of change - func setAccount(account: String) { + func setAccount(account: String?) { + guard let account + else { + self.tblAccount = nil + self.alias = "" + return + } if let tableAccount = database.getTableAccount(predicate: NSPredicate(format: "account == %@", account)) { self.tblAccount = tableAccount self.alias = tableAccount.alias @@ -170,14 +176,10 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling { /// Function to delete the current account func deleteAccount() { if let tblAccount { - NCAccount().deleteAccount(tblAccount.account) - if let account = database.getAllTableAccount().first?.account { - NCAccount().changeAccount(account, userProfile: nil, controller: self.controller) { - onViewAppear() - } - } else { + NCAccount().deleteAccount(tblAccount.account) { + let account = database.getAllTableAccount().first?.account + setAccount(account: account) dismissView = true - appDelegate.openLogin(selector: NCGlobal.shared.introLogin) } } } diff --git a/iOSClient/Account Settings/NCAccountSettingsView.swift b/iOSClient/Account Settings/NCAccountSettingsView.swift index 944a1dd7d7..4ba6ff8379 100644 --- a/iOSClient/Account Settings/NCAccountSettingsView.swift +++ b/iOSClient/Account Settings/NCAccountSettingsView.swift @@ -50,7 +50,7 @@ struct NCAccountSettingsView: View { Image(uiImage: avatar) .resizable() .scaledToFit() - .frame(width: UIScreen.main.bounds.width, height: 75) + .frame(width: UIScreen.main.bounds.width, height: 65) if let statusImage = status.statusImage { ZStack { Circle() diff --git a/iOSClient/Files/NCFiles.swift b/iOSClient/Files/NCFiles.swift index 54f09950f7..0bb1dc3f75 100644 --- a/iOSClient/Files/NCFiles.swift +++ b/iOSClient/Files/NCFiles.swift @@ -342,6 +342,7 @@ class NCFiles: NCCollectionViewCommon { override func accountSettingsDidDismiss(tableAccount: tableAccount?, controller: NCMainTabBarController?) { let currentAccount = session.account + if database.getAllTableAccount().isEmpty { appDelegate.openLogin(selector: NCGlobal.shared.introLogin) } else if let account = tableAccount?.account, account != currentAccount { @@ -350,5 +351,7 @@ class NCFiles: NCCollectionViewCommon { titleCurrentFolder = getNavigationTitle() navigationItem.title = titleCurrentFolder } + + setNavigationLeftItems() } } diff --git a/iOSClient/NCAccount.swift b/iOSClient/NCAccount.swift index ebb0de9013..9464120dd0 100644 --- a/iOSClient/NCAccount.swift +++ b/iOSClient/NCAccount.swift @@ -99,7 +99,7 @@ class NCAccount: NSObject { completion() } - func deleteAccount(_ account: String, wipe: Bool = true) { + func deleteAccount(_ account: String, wipe: Bool = true, completion: () -> Void = {}) { UIApplication.shared.allSceneSessionDestructionExceptFirst() /// Unsubscribing Push Notification @@ -129,6 +129,8 @@ class NCAccount: NSObject { NCKeychain().clearAllKeysPushNotification(account: account) /// Remove User Default Data NCNetworking.shared.removeAllKeyUserDefaultsData(account: account) + + completion() } func deleteAllAccounts() { diff --git a/iOSClient/Networking/NCService.swift b/iOSClient/Networking/NCService.swift index e6ba678492..89f9e687df 100644 --- a/iOSClient/Networking/NCService.swift +++ b/iOSClient/Networking/NCService.swift @@ -149,13 +149,16 @@ class NCService: NSObject { avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag, account: account, - options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { _, _, _, etag, _, error in - if let etag = etag, error == .success { - self.database.addAvatar(fileName: fileName, etag: etag) + options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { _, _, _, newEtag, _, error in + if let newEtag, + etag != newEtag, + error == .success { + self.database.addAvatar(fileName: fileName, etag: newEtag) + + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: ["error": error]) } else if error.errorCode == NCGlobal.shared.errorNotModified { self.database.setAvatarLoaded(fileName: fileName) } - NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: ["error": error]) } }