Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI fix #3238

Merged
merged 3 commits into from
Dec 13, 2024
Merged

UI fix #3238

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions iOSClient/Account Settings/NCAccountSettingsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Account Settings/NCAccountSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions iOSClient/Files/NCFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -350,5 +351,7 @@ class NCFiles: NCCollectionViewCommon {
titleCurrentFolder = getNavigationTitle()
navigationItem.title = titleCurrentFolder
}

setNavigationLeftItems()
}
}
4 changes: 3 additions & 1 deletion iOSClient/NCAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -129,6 +129,8 @@ class NCAccount: NSObject {
NCKeychain().clearAllKeysPushNotification(account: account)
/// Remove User Default Data
NCNetworking.shared.removeAllKeyUserDefaultsData(account: account)

completion()
}

func deleteAllAccounts() {
Expand Down
11 changes: 7 additions & 4 deletions iOSClient/Networking/NCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
}

Expand Down
Loading