diff --git a/iOSClient/Favorites/NCFavorite.swift b/iOSClient/Favorites/NCFavorite.swift index 0f8736c3d1..cb5bd4cfb6 100644 --- a/iOSClient/Favorites/NCFavorite.swift +++ b/iOSClient/Favorites/NCFavorite.swift @@ -71,7 +71,7 @@ class NCFavorite: NCCollectionViewCommon { override func getServerData(forced: Bool = false) async { defer { - restoreDefaultTitle() + stopGUIGetServerData() startSyncMetadata(metadatas: self.dataSource.getMetadatas()) } @@ -80,7 +80,7 @@ class NCFavorite: NCCollectionViewCommon { return } - showLoadingTitle() + startGUIGetServerData() let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account) let resultsListingFavorites = await NextcloudKit.shared.listingFavoritesAsync(showHiddenFiles: showHiddenFiles, diff --git a/iOSClient/Files/NCFiles.swift b/iOSClient/Files/NCFiles.swift index 565fe12e30..2a443ab17d 100644 --- a/iOSClient/Files/NCFiles.swift +++ b/iOSClient/Files/NCFiles.swift @@ -181,7 +181,7 @@ class NCFiles: NCCollectionViewCommon { override func getServerData(forced: Bool = false) async { defer { - restoreDefaultTitle() + stopGUIGetServerData() startSyncMetadata(metadatas: self.dataSource.getMetadatas()) } @@ -266,7 +266,7 @@ class NCFiles: NCCollectionViewCommon { return (nil, NKError(), reloadRequired) } - showLoadingTitle() + startGUIGetServerData() let options = NKRequestOptions(timeout: 180) let (account, metadataFolder, metadatas, error) = await NCNetworking.shared.readFolderAsync(serverUrl: serverUrl, diff --git a/iOSClient/Groupfolders/NCGroupfolders.swift b/iOSClient/Groupfolders/NCGroupfolders.swift index 09c31c428c..5709711ddd 100644 --- a/iOSClient/Groupfolders/NCGroupfolders.swift +++ b/iOSClient/Groupfolders/NCGroupfolders.swift @@ -89,7 +89,7 @@ class NCGroupfolders: NCCollectionViewCommon { override func getServerData(forced: Bool = false) async { defer { - restoreDefaultTitle() + stopGUIGetServerData() } // If is already in-flight, do nothing @@ -97,7 +97,7 @@ class NCGroupfolders: NCCollectionViewCommon { return } - showLoadingTitle() + startGUIGetServerData() let homeServerUrl = utilityFileSystem.getHomeServer(session: session) let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index 3325b714da..e8080bb079 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift @@ -523,7 +523,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { emptyTitle = NSLocalizedString("_search_no_record_found_", comment: "") } emptyDescription = NSLocalizedString("_search_instruction_", comment: "") - } else if self.searchDataSourceTask?.state == .running { + } else if self.searchDataSourceTask?.state == .running || !self.dataSource.getGetServerData() { emptyImage = utility.loadImage(named: "wifi", colors: [NCBrandColor.shared.getElement(account: session.account)]) emptyTitle = NSLocalizedString("_request_in_progress_", comment: "") emptyDescription = "" diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 03b4ad892d..ad09d5b6f2 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -524,7 +524,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS func accountSettingsDidDismiss(tblAccount: tableAccount?, controller: NCMainTabBarController?) { } @MainActor - func showLoadingTitle() { + func startGUIGetServerData() { + self.dataSource.setGetServerData(false) + self.collectionView.reloadData() + // Don't show spinner on iPad root folder if UIDevice.current.userInterfaceIdiom == .pad, (self.serverUrl == self.utilityFileSystem.getHomeServer(session: self.session)) || self.serverUrl.isEmpty { @@ -548,7 +551,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS } @MainActor - func restoreDefaultTitle() { + func stopGUIGetServerData() { + self.dataSource.setGetServerData(true) self.navigationItem.titleView = nil self.navigationItem.title = self.titleCurrentFolder } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewDataSource.swift index 52cb15b3fe..0de361ad3a 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewDataSource.swift @@ -20,6 +20,7 @@ class NCCollectionViewDataSource: NSObject { private var layoutForView: NCDBLayoutForView? private var directoryOnTop: Bool = true private var favoriteOnTop: Bool = true + private var hasGetServerData: Bool = true override init() { super.init() } @@ -48,6 +49,16 @@ class NCCollectionViewDataSource: NSObject { // MARK: - + func getGetServerData() -> Bool { + return hasGetServerData + } + + func setGetServerData(_ state: Bool) { + hasGetServerData = state + } + + // MARK: - + func removeAll() { self.metadatas.removeAll() self.metadatasForSection.removeAll() diff --git a/iOSClient/Networking/NCNetworking+WebDAV.swift b/iOSClient/Networking/NCNetworking+WebDAV.swift index fdb2c8428a..2d3d19b5e7 100644 --- a/iOSClient/Networking/NCNetworking+WebDAV.swift +++ b/iOSClient/Networking/NCNetworking+WebDAV.swift @@ -26,6 +26,7 @@ extension NCNetworking { name: "readFileOrFolder") await NCNetworking.shared.networkingTasks.track(identifier: identifier, task: task) } + taskHandler(task) } guard resultsReadFolder.error == .success, let files = resultsReadFolder.files else { diff --git a/iOSClient/Offline/NCOffline.swift b/iOSClient/Offline/NCOffline.swift index 1d3d282b89..c677762068 100644 --- a/iOSClient/Offline/NCOffline.swift +++ b/iOSClient/Offline/NCOffline.swift @@ -47,7 +47,7 @@ class NCOffline: NCCollectionViewCommon { super.viewWillAppear(animated) Task { - await self.reloadDataSource() + await getServerData() } } @@ -86,6 +86,10 @@ class NCOffline: NCCollectionViewCommon { } override func getServerData(forced: Bool = false) async { + defer { + stopGUIGetServerData() + } + await self.reloadDataSource() } } diff --git a/iOSClient/Recent/NCRecent.swift b/iOSClient/Recent/NCRecent.swift index d1ebd85b42..2379b3ab4e 100644 --- a/iOSClient/Recent/NCRecent.swift +++ b/iOSClient/Recent/NCRecent.swift @@ -83,7 +83,7 @@ class NCRecent: NCCollectionViewCommon { override func getServerData(forced: Bool = false) async { defer { - restoreDefaultTitle() + stopGUIGetServerData() } // If is already in-flight, do nothing @@ -160,7 +160,7 @@ class NCRecent: NCCollectionViewCommon { let requestBody = String(format: requestBodyRecent, "/files/" + session.userId, lessDateString) let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account) - showLoadingTitle() + startGUIGetServerData() let resultsSearch = await NextcloudKit.shared.searchBodyRequestAsync(serverUrl: session.urlBase, requestBody: requestBody, diff --git a/iOSClient/Shares/NCShares.swift b/iOSClient/Shares/NCShares.swift index f60b9f8d81..c00af453eb 100644 --- a/iOSClient/Shares/NCShares.swift +++ b/iOSClient/Shares/NCShares.swift @@ -76,7 +76,7 @@ class NCShares: NCCollectionViewCommon { return } - showLoadingTitle() + startGUIGetServerData() let resultsReadShares = await NextcloudKit.shared.readSharesAsync(parameters: NKShareParameter(), account: session.account) { task in Task { @@ -88,8 +88,8 @@ class NCShares: NCCollectionViewCommon { } guard resultsReadShares.error == .success else { + self.stopGUIGetServerData() await self.reloadDataSource() - self.restoreDefaultTitle() return } @@ -134,7 +134,7 @@ class NCShares: NCCollectionViewCommon { } Task { - await self.restoreDefaultTitle() + await self.stopGUIGetServerData() await self.reloadDataSource() await self.startSyncMetadata(metadatas: self.dataSource.getMetadatas()) }