Skip to content
Merged
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
4 changes: 2 additions & 2 deletions iOSClient/Favorites/NCFavorite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class NCFavorite: NCCollectionViewCommon {

override func getServerData(forced: Bool = false) async {
defer {
restoreDefaultTitle()
stopGUIGetServerData()
startSyncMetadata(metadatas: self.dataSource.getMetadatas())
}

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Files/NCFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class NCFiles: NCCollectionViewCommon {

override func getServerData(forced: Bool = false) async {
defer {
restoreDefaultTitle()
stopGUIGetServerData()
startSyncMetadata(metadatas: self.dataSource.getMetadatas())
}

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Groupfolders/NCGroupfolders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ class NCGroupfolders: NCCollectionViewCommon {

override func getServerData(forced: Bool = false) async {
defer {
restoreDefaultTitle()
stopGUIGetServerData()
}

// If is already in-flight, do nothing
if await NCNetworking.shared.networkingTasks.isReading(identifier: "NCGroupfolders") {
return
}

showLoadingTitle()
startGUIGetServerData()

let homeServerUrl = utilityFileSystem.getHomeServer(session: session)
let showHiddenFiles = NCPreferences().getShowHiddenFiles(account: session.account)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
8 changes: 6 additions & 2 deletions iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
11 changes: 11 additions & 0 deletions iOSClient/Main/Collection Common/NCCollectionViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() }

Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions iOSClient/Networking/NCNetworking+WebDAV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion iOSClient/Offline/NCOffline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NCOffline: NCCollectionViewCommon {
super.viewWillAppear(animated)

Task {
await self.reloadDataSource()
await getServerData()
}
}

Expand Down Expand Up @@ -86,6 +86,10 @@ class NCOffline: NCCollectionViewCommon {
}

override func getServerData(forced: Bool = false) async {
defer {
stopGUIGetServerData()
}

await self.reloadDataSource()
}
}
4 changes: 2 additions & 2 deletions iOSClient/Recent/NCRecent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class NCRecent: NCCollectionViewCommon {

override func getServerData(forced: Bool = false) async {
defer {
restoreDefaultTitle()
stopGUIGetServerData()
}

// If is already in-flight, do nothing
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions iOSClient/Shares/NCShares.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class NCShares: NCCollectionViewCommon {
return
}

showLoadingTitle()
startGUIGetServerData()

let resultsReadShares = await NextcloudKit.shared.readSharesAsync(parameters: NKShareParameter(), account: session.account) { task in
Task {
Expand All @@ -88,8 +88,8 @@ class NCShares: NCCollectionViewCommon {
}

guard resultsReadShares.error == .success else {
self.stopGUIGetServerData()
await self.reloadDataSource()
self.restoreDefaultTitle()
return
}

Expand Down Expand Up @@ -134,7 +134,7 @@ class NCShares: NCCollectionViewCommon {
}

Task {
await self.restoreDefaultTitle()
await self.stopGUIGetServerData()
await self.reloadDataSource()
await self.startSyncMetadata(metadatas: self.dataSource.getMetadatas())
}
Expand Down
Loading