Skip to content

Commit 03a4d5c

Browse files
3397 transfer system queue refactoring (#3995)
1 parent a70d6b0 commit 03a4d5c

22 files changed

Lines changed: 804 additions & 722 deletions

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 25 additions & 46 deletions
Large diffs are not rendered by default.

iOSClient/Activity/NCActivityNavigationController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import UIKit
66

77
class NCActivityNavigationController: NCMainNavigationController {
8-
override func createRightMenu() async -> UIMenu? {
8+
override func createOptionMenu() async -> UIMenu? {
99
return nil
1010
}
1111
}

iOSClient/Extensions/NotificationCenter+MainThread.swift renamed to iOSClient/Extensions/NotificationCenter+Extension.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ extension NotificationCenter {
3030
NotificationCenter.default.post(name: Notification.Name(rawValue: name), object: anObject, userInfo: aUserInfo)
3131
}
3232
}
33+
34+
func postOnGlobalThread(name: String, object anObject: Any? = nil, userInfo aUserInfo: [AnyHashable: Any]? = nil, second: Double = 0) {
35+
DispatchQueue.global().asyncAfter(deadline: .now() + second) {
36+
NotificationCenter.default.post(name: Notification.Name(rawValue: name), object: anObject, userInfo: aUserInfo)
37+
}
38+
}
3339
}

iOSClient/Extensions/UIAlertController+Extension.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ extension UIAlertController {
7676
await NCNetworkingE2EECreateFolder().createFolder(fileName: fileNameFolder, serverUrl: serverUrl, sceneIdentifier: sceneIdentifier, session: session)
7777
}
7878
} else {
79-
#if EXTENSION
79+
#if EXTENSION
8080
Task {
8181
let error = await NCNetworking.shared.createFolder(fileName: fileNameFolder, serverUrl: serverUrl, overwrite: false, session: session)
8282
completion?(error)
8383
}
84-
#else
84+
#else
8585
var metadata = tableMetadata()
8686

8787
if let result = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView == %@", session.account, serverUrl, fileNameFolder)) {
@@ -99,6 +99,16 @@ extension UIAlertController {
9999
metadata.sessionDate = Date()
100100

101101
NCManageDatabase.shared.addMetadata(metadata)
102+
103+
Task {
104+
// START Networking Process
105+
NotificationCenter.default.postOnGlobalThread(name: NCGlobal.shared.notificationCenterNetworkingProcess)
106+
107+
// RELOAD
108+
await NCNetworking.shared.transferDispatcher.notifyAllDelegates { delegate in
109+
delegate.transferReloadDataSource(serverUrl: metadata.serverUrl, requestData: false, status: NCGlobal.shared.metadataStatusWaitCreateFolder)
110+
}
111+
}
102112
#endif
103113
}
104114
})

iOSClient/Favorites/NCFavoriteNavigationController.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ class NCFavoriteNavigationController: NCMainNavigationController {
88

99
// MARK: - Right
1010

11-
override func createRightMenu() async -> UIMenu? {
12-
guard let items = await self.createRightMenuActions(),
13-
let collectionViewCommon
14-
else {
11+
override func createOptionMenu() async -> UIMenu? {
12+
guard let collectionViewCommon,
13+
let items = await NCContextMenuNavigation().viewMenuOption(
14+
collectionViewCommon: collectionViewCommon,
15+
mainNavigationController: self,
16+
session: session
17+
) else {
1518
return nil
1619
}
1720

iOSClient/Files/NCFiles.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ class NCFiles: NCCollectionViewCommon {
114114

115115
Task {
116116
// Plus Menu reload
117-
let capabilities = await database.getCapabilities(account: self.session.account) ?? NKCapabilities.Capabilities()
118-
await mainNavigationController?.createPlusMenu(session: self.session, capabilities: capabilities)
117+
await self.mainNavigationController?.menuPlus?.create(session: session)
118+
119119
// Server data
120120
if !isSearchingMode {
121121
await getServerData()

iOSClient/Files/NCFilesNavigationController.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ class NCFilesNavigationController: NCMainNavigationController {
2929

3030
// MARK: - Right
3131

32-
override func createRightMenu() async -> UIMenu? {
33-
guard let items = await self.createRightMenuActions(),
34-
let collectionViewCommon
32+
override func createOptionMenu() async -> UIMenu? {
33+
guard let collectionViewCommon,
34+
let items = await NCContextMenuNavigation().viewMenuOption(
35+
collectionViewCommon: collectionViewCommon,
36+
mainNavigationController: self,
37+
session: self.session)
3538
else {
3639
return nil
3740
}

iOSClient/GUI/Lucid Banner/BannerView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,12 @@ func bannerContainsError(errorCode: Int?, afError: AFError? = nil) -> Bool {
309309
// The same error code is shown to the user only once.
310310
// Error 401 (maintenance mode)
311311
// Error 507 (insufficient storage)
312-
if errorCode == 401 || errorCode == 507 {
312+
// Error -1009 (NSURLErrorNotConnectedToInternet)
313+
// Error -1003 (NSURLError​Cannot​Find​Host)
314+
if errorCode == 401 ||
315+
errorCode == 507 ||
316+
errorCode == NSURLErrorNotConnectedToInternet ||
317+
errorCode == NSURLErrorCannotFindHost {
313318
shownErrors.insert(errorCode)
314319
}
315320
return false

iOSClient/Main/Collection Common/NCCollectionViewCommon+SelectTabBarDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate {
126126
navigationItem.hidesBackButton = editMode
127127
navigationController?.interactivePopGestureRecognizer?.isEnabled = !editMode
128128
searchController(enabled: !editMode)
129-
mainNavigationController?.hiddenPlusButton(editMode)
129+
130+
// (+)
131+
mainNavigationController?.menuPlus?.hiddenPlusButton(editMode)
130132

131133
if editMode {
132134
navigationItem.leftBarButtonItems = nil

iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
225225

226226
// Wait 1.5 seconds before resetting the button alpha
227227
try? await Task.sleep(for: .seconds(1.5))
228-
self.mainNavigationController?.resetPlusButtonAlpha()
228+
self.mainNavigationController?.menuPlus?.resetPlusButtonAlpha()
229229
}
230230
}
231231

@@ -384,7 +384,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
384384
// MARK: - NotificationCenter
385385

386386
@objc func applicationWillResignActive(_ notification: NSNotification) {
387-
mainNavigationController?.resetPlusButtonAlpha()
387+
self.mainNavigationController?.menuPlus?.resetPlusButtonAlpha()
388388
}
389389

390390
@objc func closeRichWorkspaceWebView() {
@@ -428,7 +428,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
428428
self.collectionView.collectionViewLayout.invalidateLayout()
429429

430430
Task {
431-
await (self.navigationController as? NCMainNavigationController)?.updateRightMenu()
431+
await (self.navigationController as? NCMainNavigationController)?.updateMenuOption()
432432
}
433433
}
434434

@@ -512,9 +512,10 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
512512
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
513513
// TIP
514514
dismissTip()
515-
//
516-
mainNavigationController?.hiddenPlusButton(true)
517-
//
515+
516+
// (+)
517+
self.mainNavigationController?.menuPlus?.hiddenPlusButton(true)
518+
518519
if !isSearchingMode {
519520
self.isSearchingMode = true
520521
self.dataSource.removeAll()
@@ -533,7 +534,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
533534

534535
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
535536
// (+)
536-
mainNavigationController?.hiddenPlusButton(false)
537+
self.mainNavigationController?.menuPlus?.hiddenPlusButton(false)
537538

538539
self.isSearchingMode = false
539540
self.networkSearchInProgress = false
@@ -709,7 +710,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
709710
delegate.transferReloadData(serverUrl: self.serverUrl)
710711
}
711712

712-
await (self.navigationController as? NCMainNavigationController)?.updateRightMenu()
713+
await (self.navigationController as? NCMainNavigationController)?.updateMenuOption()
713714
}
714715

715716
func getServerData(forced: Bool = false) async { }
@@ -880,7 +881,8 @@ extension NCCollectionViewCommon: NCTransferDelegate {
880881
}
881882

882883
if status == self.global.networkingStatusCreateFolder {
883-
if serverUrl == self.serverUrl,
884+
if error == .success,
885+
serverUrl == self.serverUrl,
884886
selector != self.global.selectorUploadAutoUpload,
885887
let metadata = await NCManageDatabase.shared.getMetadataAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileName == %@", account, serverUrl, fileName)) {
886888
self.pushMetadata(metadata)

0 commit comments

Comments
 (0)