Browse Source

Fix #2577 : Added one second before `tipView` func call. (#2578)

* Added one second before tipView function call.

Signed-off-by: Aditya Tyagi <adityagi02@yahoo.com>

* refactor : rename

Signed-off-by: Aditya Tyagi <adityagi02@yahoo.com>

* fix

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

---------

Signed-off-by: Aditya Tyagi <adityagi02@yahoo.com>
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Co-authored-by: Marino Faggiana <marino@marinofaggiana.com>
Aditya Tyagi 1 year ago
parent
commit
bc6e181cfa

+ 1 - 1
iOSClient/Activity/NCActivity.swift

@@ -359,7 +359,7 @@ extension NCActivity {
 
         var bottom: CGFloat = 0
         if let mainTabBar = self.tabBarController?.tabBar as? NCMainTabBar {
-            bottom = -mainTabBar.getHight()
+            bottom = -mainTabBar.getHeight()
         }
         NCActivityIndicator.shared.start(backgroundView: self.view, bottom: bottom - 5, style: .medium)
 

+ 5 - 4
iOSClient/AppDelegate.swift

@@ -610,8 +610,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     @objc func settingAccount(_ account: String, urlBase: String, user: String, userId: String, password: String, initialize: Bool = true) {
 
-        let accountTestBackup = self.account + "/" + self.userId
-        let accountTest = account + "/" + userId
+        let currentAccount = self.account + "/" + self.userId
+        let newAccount = account + "/" + userId
 
         self.account = account
         self.urlBase = urlBase
@@ -629,7 +629,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
 
         DispatchQueue.main.async {
-            if initialize, UIApplication.shared.applicationState != .background && accountTestBackup != accountTest {
+            if initialize, UIApplication.shared.applicationState != .background && currentAccount != newAccount && newAccount != "/" {
                 NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize, second: 0.2)
             }
         }
@@ -651,8 +651,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         CCUtility.clearAllKeysPushNotification(account)
         CCUtility.setPassword(account, password: nil)
 
+        settingAccount("", urlBase: "", user: "", userId: "", password: "")
+
         if wipe {
-            settingAccount("", urlBase: "", user: "", userId: "", password: "")
             let accounts = NCManageDatabase.shared.getAccounts()
             if accounts?.count ?? 0 > 0 {
                 if let newAccount = accounts?.first {

+ 14 - 8
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -177,7 +177,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         NotificationCenter.default.addObserver(self, selector: #selector(applicationWillResignActive(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationWillResignActive), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(closeRichWorkspaceWebView), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterCloseRichWorkspaceWebView), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(changeStatusFolderE2EE(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeStatusFolderE2EE), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(setNavigationItem), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadAvatar), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(reloadAvatar(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadAvatar), object: nil)
 
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataSource), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSourceNetwork), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataSourceNetwork), object: nil)
@@ -221,12 +221,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
 
-    override func viewDidAppear(_ animated: Bool) {
-        super.viewDidAppear(animated)
-
-        showTip()
-    }
-
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
 
@@ -329,6 +323,18 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         self.refreshControl.endRefreshing()
     }
 
+    @objc func reloadAvatar(_ notification: NSNotification) {
+
+        guard let userInfo = notification.userInfo as NSDictionary?,
+              let error = userInfo["error"] as? NKError,
+              error.errorCode != NCGlobal.shared.errorNotModified else { return }
+
+        setNavigationItem()
+        DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
+            self.showTip()
+        }
+    }
+
     @objc func changeTheming() {
         collectionView.reloadData()
     }
@@ -617,7 +623,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     // MARK: - Layout
 
-    @objc func setNavigationItem() {
+    func setNavigationItem() {
 
         self.setNavigationRightItems()
         navigationItem.title = titleCurrentFolder

+ 1 - 1
iOSClient/Main/NCMainTabBar.swift

@@ -233,7 +233,7 @@ class NCMainTabBar: UITabBar {
         }
     }
 
-    func getHight() -> CGFloat {
+    func getHeight() -> CGFloat {
         return (frame.size.height - centerButtonY)
     }
 }

+ 1 - 1
iOSClient/Media/NCMedia.swift

@@ -533,7 +533,7 @@ extension NCMedia {
             self.collectionView.reloadData()
             var bottom: CGFloat = 0
             if let mainTabBar = self.tabBarController?.tabBar as? NCMainTabBar {
-                bottom = -mainTabBar.getHight()
+                bottom = -mainTabBar.getHeight()
             }
             NCActivityIndicator.shared.start(backgroundView: self.view, bottom: bottom - 5, style: .medium)
         }

+ 6 - 7
iOSClient/Networking/NCService.swift

@@ -149,14 +149,13 @@ class NCService: NSObject {
         let options = NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
 
         NextcloudKit.shared.downloadAvatar(user: tableAccount.userId, fileNameLocalPath: fileNameLocalPath, sizeImage: NCGlobal.shared.avatarSize, avatarSizeRounded: NCGlobal.shared.avatarSizeRounded, etag: etag, options: options) { _, _, _, etag, error in
-            guard let etag = etag, error == .success else {
-                if error.errorCode == NCGlobal.shared.errorNotModified {
-                    NCManageDatabase.shared.setAvatarLoaded(fileName: fileName)
-                }
-                return
+
+            if let etag = etag, error == .success {
+                NCManageDatabase.shared.addAvatar(fileName: fileName, etag: etag)
+            } else if error.errorCode == NCGlobal.shared.errorNotModified {
+                NCManageDatabase.shared.setAvatarLoaded(fileName: fileName)
             }
-            NCManageDatabase.shared.addAvatar(fileName: fileName, etag: etag)
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: nil)
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: ["error":error])
         }
     }