Skip to content

Commit

Permalink
improvements (#3080)
Browse files Browse the repository at this point in the history
* cod

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

* cod

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

---------

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
  • Loading branch information
marinofaggiana authored Sep 29, 2024
1 parent d5d51b5 commit 377bad4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
26 changes: 14 additions & 12 deletions iOSClient/Files/NCFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,24 @@ class NCFiles: NCCollectionViewCommon {

super.reloadDataSourceNetwork()

networkReadFolder { tableDirectory, metadatas, reloadDataSource, error in
DispatchQueue.main.async {
if error == .success {
for metadata in metadatas ?? [] where !metadata.directory && downloadMetadata(metadata) {
if NCNetworking.shared.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty {
NCNetworking.shared.downloadQueue.addOperation(NCOperationDownload(metadata: metadata, selector: NCGlobal.shared.selectorDownloadFile))
DispatchQueue.global(qos: .background).async {
self.networkReadFolder { tableDirectory, metadatas, reloadDataSource, error in
DispatchQueue.main.async {
if error == .success {
for metadata in metadatas ?? [] where !metadata.directory && downloadMetadata(metadata) {
if NCNetworking.shared.downloadQueue.operations.filter({ ($0 as? NCOperationDownload)?.metadata.ocId == metadata.ocId }).isEmpty {
NCNetworking.shared.downloadQueue.addOperation(NCOperationDownload(metadata: metadata, selector: NCGlobal.shared.selectorDownloadFile))
}
}
}

self.richWorkspaceText = tableDirectory?.richWorkspace
self.richWorkspaceText = tableDirectory?.richWorkspace

if reloadDataSource {
self.reloadDataSource()
if reloadDataSource {
self.reloadDataSource()
}
} else {
self.reloadDataSource(withQueryDB: withQueryDB)
}
} else {
self.reloadDataSource(withQueryDB: withQueryDB)
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions iOSClient/Networking/NCAutoUpload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ class NCAutoUpload: NSObject {
// MARK: -

func initAutoUpload(controller: NCMainTabBarController?, account: String, completion: @escaping (_ num: Int) -> Void) {
guard NCNetworking.shared.isOnline,
let tableAccount = self.database.getTableAccount(predicate: NSPredicate(format: "account == %@", account)),
tableAccount.autoUpload else {
return completion(0)
}
applicationState = UIApplication.shared.applicationState

NCAskAuthorization().askAuthorizationPhotoLibrary(controller: controller) { hasPermission in
guard hasPermission else {
self.database.setAccountAutoUploadProperty("autoUpload", state: false)
DispatchQueue.global(qos: .userInteractive).async {
guard NCNetworking.shared.isOnline,
let tableAccount = self.database.getTableAccount(predicate: NSPredicate(format: "account == %@", account)),
tableAccount.autoUpload else {
return completion(0)
}
DispatchQueue.global(qos: .userInteractive).async {

NCAskAuthorization().askAuthorizationPhotoLibrary(controller: controller) { hasPermission in
guard hasPermission else {
self.database.setAccountAutoUploadProperty("autoUpload", state: false)
return completion(0)
}

self.uploadAssetsNewAndFull(controller: controller, selector: NCGlobal.shared.selectorUploadAutoUpload, log: "Init Auto Upload", account: account) { num in
completion(num)
}
Expand Down
8 changes: 4 additions & 4 deletions iOSClient/Networking/NCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class NCService: NSObject {
return
}

self.database.clearAllAvatarLoaded()
NCPushNotification.shared.pushNotification()

Task {
Task(priority: .background) {
self.database.clearAllAvatarLoaded()
NCPushNotification.shared.pushNotification()
addInternalTypeIdentifier(account: account)

let result = await requestServerStatus(account: account, controller: controller)
if result {
requestServerCapabilities(account: account)
Expand Down

0 comments on commit 377bad4

Please sign in to comment.