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

Scan - Improvements #2610

Merged
merged 22 commits into from
Sep 29, 2023
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
9 changes: 3 additions & 6 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Create share accounts \(error.localizedDescription)")
}

NCOperationQueue.shared.cancelAllQueue()
NCNetworking.shared.cancelAllDownloadTransfer()
NextcloudKit.shared.sessionManager.cancelAllRequests()
NCNetworking.shared.cancelSessions(inBackground: false)

presentPasscode { }

Expand All @@ -269,7 +267,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
// L'applicazione terminerà
func applicationWillTerminate(_ application: UIApplication) {

NCNetworking.shared.cancelAllDownloadTransfer()
NCNetworking.shared.cancelSessions(inBackground: false)

if UIApplication.shared.backgroundRefreshStatus == .available {

Expand Down Expand Up @@ -560,8 +558,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else { return }

NCOperationQueue.shared.cancelAllQueue()
NCNetworking.shared.cancelAllTask()
NCNetworking.shared.cancelSessions(inBackground: false)

self.account = tableAccount.account
self.urlBase = tableAccount.urlBase
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Color/NCColorPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class NCColorPicker: UIViewController {
let serverUrl = metadata.serverUrl + "/" + metadata.fileName
if NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, colorFolder: hexColor, account: metadata.account) != nil {
self.dismiss(animated: true)
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": metadata.serverUrl])
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource)
}
}
self.dismiss(animated: true)
Expand Down
45 changes: 23 additions & 22 deletions iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@

for index in metadatas.indices {
let metadata = metadatas[index]
if index < metadatas.count - 1,

Check warning on line 393 in iOSClient/Data/NCManageDatabase+Metadata.swift

View workflow job for this annotation

GitHub Actions / Lint

Control Statement Violation: `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
metadata.fileNoExtension == metadatas[index + 1].fileNoExtension,
((metadata.classFile == NKCommon.TypeClassFile.image.rawValue && metadatas[index + 1].classFile == NKCommon.TypeClassFile.video.rawValue) || (metadata.classFile == NKCommon.TypeClassFile.video.rawValue && metadatas[index + 1].classFile == NKCommon.TypeClassFile.image.rawValue)) {
metadata.livePhoto = true
Expand Down Expand Up @@ -631,28 +631,29 @@
do {
let realm = try Realm()
try realm.write {
let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first
if let newFileName = newFileName {
result?.fileName = newFileName
result?.fileNameView = newFileName
}
if let session = session {
result?.session = session
}
if let sessionError = sessionError {
result?.sessionError = sessionError
}
if let sessionSelector = sessionSelector {
result?.sessionSelector = sessionSelector
}
if let sessionTaskIdentifier = sessionTaskIdentifier {
result?.sessionTaskIdentifier = sessionTaskIdentifier
}
if let status = status {
result?.status = status
}
if let etag = etag {
result?.etag = etag
if let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first {
if let newFileName = newFileName {
result.fileName = newFileName
result.fileNameView = newFileName
}
if let session = session {
result.session = session
}
if let sessionError = sessionError {
result.sessionError = sessionError
}
if let sessionSelector = sessionSelector {
result.sessionSelector = sessionSelector
}
if let sessionTaskIdentifier = sessionTaskIdentifier {
result.sessionTaskIdentifier = sessionTaskIdentifier
}
if let status = status {
result.status = status
}
if let etag = etag {
result.etag = etag
}
}
}
} catch let error {
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 @@ -801,7 +801,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
if namedButtonMore == NCGlobal.shared.buttonMoreMore || namedButtonMore == NCGlobal.shared.buttonMoreLock {
toggleMenu(metadata: metadata, indexPath: indexPath, imageIcon: image)
} else if namedButtonMore == NCGlobal.shared.buttonMoreStop {
NCNetworking.shared.cancelTransferMetadata(metadata) { }
Task {
await NCNetworking.shared.cancel(metadata: metadata)
}
}
}

Expand All @@ -826,7 +828,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
func tapButtonTransfer(_ sender: Any) {
if let ocId = NCNetworking.shared.transferInForegorund?.ocId,
let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
NCNetworking.shared.cancelTransferMetadata(metadata) { }
Task {
await NCNetworking.shared.cancel(metadata: metadata)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Menu/NCSortMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ class NCSortMenu: NSObject {

self.sortButton?.setTitle(NSLocalizedString(layoutForView.titleButtonHeader, comment: ""), for: .normal)
NCManageDatabase.shared.setLayoutForView(layoutForView: layoutForView)
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl": self.serverUrl])
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource)
}
}
7 changes: 4 additions & 3 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ class NCGlobal: NSObject {
@objc let errorUnauthorized401: Int = 401
@objc let errorForbidden: Int = 403
@objc let errorResourceNotFound: Int = 404
@objc let errordMethodNotSupported: Int = 405
@objc let errorMethodNotSupported: Int = 405
@objc let errorConflict: Int = 409
@objc let errorPreconditionFailed: Int = 412
@objc let errorQuota: Int = 507
@objc let errorUnauthorized997: Int = 997
@objc let errorConnectionLost: Int = -1005
@objc let errorNetworkNotAvailable: Int = -1009
Expand Down Expand Up @@ -348,8 +349,8 @@ class NCGlobal: NSObject {
let notificationCenterUpdateBadgeNumber = "updateBadgeNumber" // userInfo: counter
let notificationCenterReloadAvatar = "reloadAvatar"

@objc let notificationCenterReloadDataSource = "reloadDataSource" // userInfo: serverUrl?
let notificationCenterReloadDataSourceNetwork = "reloadDataSourceNetwork" // userInfo: serverUrl?
@objc let notificationCenterReloadDataSource = "reloadDataSource"
let notificationCenterReloadDataSourceNetwork = "reloadDataSourceNetwork"
let notificationCenterReloadDataSourceNetworkForced = "reloadDataSourceNetworkForced"

let notificationCenterChangeStatusFolderE2EE = "changeStatusFolderE2EE" // userInfo: serverUrl
Expand Down
Loading
Loading