Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarino Faggiana <marino@marinofaggiana.com>2022-09-30 18:11:10 +0300
committerMarino Faggiana <marino@marinofaggiana.com>2022-09-30 18:11:10 +0300
commit43a10674925b533935b20d9893ddebd7ba6a55e4 (patch)
tree28bbaebe274e9686507675d260a614a78b71b8cc
parentade02e1a4eb512350712a1447fe44643f5c703b9 (diff)
fix activity
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
-rw-r--r--iOSClient/Activity/NCActivityTableViewCell.swift63
-rw-r--r--iOSClient/Utility/NCActivityIndicator.swift2
2 files changed, 20 insertions, 45 deletions
diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift
index f2d11db58..d259506ef 100644
--- a/iOSClient/Activity/NCActivityTableViewCell.swift
+++ b/iOSClient/Activity/NCActivityTableViewCell.swift
@@ -140,54 +140,29 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
}
}
- var pathComponents = activityPreview.link.components(separatedBy: "?")
- pathComponents = pathComponents[1].components(separatedBy: "&")
- var serverUrlFileName = pathComponents[0].replacingOccurrences(of: "dir=", with: "").removingPercentEncoding!
- serverUrlFileName = NCUtilityFileSystem.shared.getHomeServer(account: activityPreview.account) + serverUrlFileName + "/" + activitySubjectRich.name
- let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(activitySubjectRich.id, fileNameView: activitySubjectRich.name)!
-
- if let backgroundView = appDelegate.window?.rootViewController?.view {
- NCActivityIndicator.shared.start(backgroundView: backgroundView)
- }
-
- NextcloudKit.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
-
- }, taskHandler: { _ in
-
- }, progressHandler: { _ in
-
- }) { account, _, _, _, _, _, error in
-
- if account == self.appDelegate.account && error == .success {
-
- let serverUrl = (serverUrlFileName as NSString).deletingLastPathComponent
- let fileName = (serverUrlFileName as NSString).lastPathComponent
- let serverUrlFileName = serverUrl + "/" + fileName
-
- NCNetworking.shared.readFile(serverUrlFileName: serverUrlFileName) { account, metadata, error in
-
+ NCActivityIndicator.shared.start()
+ NextcloudKit.shared.getFileFromFileId(nil, link: activityPreview.link) { account, file, data, error in
+ if let file = file {
+
+ let metadata = NCManageDatabase.shared.convertNCFileToMetadata(file, isEncrypted: file.e2eEncrypted, account: account)
+ NCManageDatabase.shared.addMetadata(metadata)
+
+ let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
+ let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+
+ NextcloudKit.shared.download(serverUrlFileName: serverUrlFileName, fileNameLocalPath: fileNameLocalPath, requestHandler: { _ in
+ }, taskHandler: { _ in
+ }, progressHandler: { _ in
+ }) { account, _, _, _, _, _, error in
NCActivityIndicator.shared.stop()
-
- DispatchQueue.main.async {
- if account == self.appDelegate.account, error == .success, let metadata = metadata {
-
- // move from id to oc:id + instanceid (ocId)
- let atPath = CCUtility.getDirectoryProviderStorage()! + "/" + activitySubjectRich.id
- let toPath = CCUtility.getDirectoryProviderStorage()! + "/" + metadata.ocId
-
- CCUtility.moveFile(atPath: atPath, toPath: toPath)
-
- NCManageDatabase.shared.addMetadata(metadata)
- if let viewController = self.viewController {
- NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: cell?.imageView.image)
- }
+ if account == self.appDelegate.account && error == .success {
+ if let viewController = self.viewController {
+ NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: cell?.imageView.image)
}
}
}
-
- } else {
-
- NCActivityIndicator.shared.stop()
+ } else if error != .success {
+ NCContentPresenter.shared.showError(error: error)
}
}
}
diff --git a/iOSClient/Utility/NCActivityIndicator.swift b/iOSClient/Utility/NCActivityIndicator.swift
index 9d0f6614f..e10f5e644 100644
--- a/iOSClient/Utility/NCActivityIndicator.swift
+++ b/iOSClient/Utility/NCActivityIndicator.swift
@@ -38,7 +38,7 @@ class NCActivityIndicator: NSObject {
start(backgroundView: backgroundView, style: style)
}
- func start(backgroundView: UIView? = nil, bottom: CGFloat? = nil, top: CGFloat? = nil, style: UIActivityIndicatorView.Style = .whiteLarge) {
+ func start(backgroundView: UIView? = nil, bottom: CGFloat? = nil, top: CGFloat? = nil, style: UIActivityIndicatorView.Style = .large) {
if self.activityIndicator != nil { stop() }