diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 1597e80db7..b6160397fc 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -5815,7 +5815,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -5881,7 +5881,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; diff --git a/iOSClient/Data/NCManageDatabase+Metadata.swift b/iOSClient/Data/NCManageDatabase+Metadata.swift index 7adc06e127..b9a48061c4 100644 --- a/iOSClient/Data/NCManageDatabase+Metadata.swift +++ b/iOSClient/Data/NCManageDatabase+Metadata.swift @@ -1208,12 +1208,14 @@ extension NCManageDatabase { return false } - func getResultMetadataFromFileId(_ fileId: String?) -> tableMetadata? { + func getMetadataFromFileId(_ fileId: String?) -> tableMetadata? { guard let fileId else { return nil } do { let realm = try Realm() - return realm.objects(tableMetadata.self).filter("fileId == %@", fileId).first + if let result = realm.objects(tableMetadata.self).filter("fileId == %@", fileId).first { + return tableMetadata(value: result) + } } catch let error as NSError { NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Could not access database: \(error)") } diff --git a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionFirstHeader.swift b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionFirstHeader.swift index 27d81de6b1..254cf41298 100644 --- a/iOSClient/Main/Collection Common/Section Header Footer/NCSectionFirstHeader.swift +++ b/iOSClient/Main/Collection Common/Section Header Footer/NCSectionFirstHeader.swift @@ -172,7 +172,7 @@ extension NCSectionFirstHeader: UICollectionViewDataSource { let recommendedFiles = self.recommendations[indexPath.row] guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? NCRecommendationsCell else { fatalError() } - if let metadata = NCManageDatabase.shared.getResultMetadataFromFileId(recommendedFiles.id) { + if let metadata = NCManageDatabase.shared.getMetadataFromFileId(recommendedFiles.id) { let imagePreview = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: NCGlobal.shared.previewExt512) if metadata.directory { @@ -229,7 +229,7 @@ extension NCSectionFirstHeader: UICollectionViewDataSource { extension NCSectionFirstHeader: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let recommendedFiles = self.recommendations[indexPath.row] - guard let metadata = NCManageDatabase.shared.getResultMetadataFromFileId(recommendedFiles.id) else { + guard let metadata = NCManageDatabase.shared.getMetadataFromFileId(recommendedFiles.id) else { return } @@ -238,7 +238,7 @@ extension NCSectionFirstHeader: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { let recommendedFiles = self.recommendations[indexPath.row] - guard let metadata = NCManageDatabase.shared.getResultMetadataFromFileId(recommendedFiles.id), + guard let metadata = NCManageDatabase.shared.getMetadataFromFileId(recommendedFiles.id), metadata.classFile != NKCommon.TypeClassFile.url.rawValue, let viewController else { return nil diff --git a/iOSClient/Main/NCActionCenter.swift b/iOSClient/Main/NCActionCenter.swift index 74dddd1fcd..f777147968 100644 --- a/iOSClient/Main/NCActionCenter.swift +++ b/iOSClient/Main/NCActionCenter.swift @@ -197,8 +197,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec var downloadRequest: DownloadRequest? let hud = NCHud(viewController.tabBarController?.view) - if let metadata = database.getResultMetadataFromFileId(fileId) { - let metadata = tableMetadata(value: metadata) + if let metadata = database.getMetadataFromFileId(fileId) { do { let attr = try FileManager.default.attributesOfItem(atPath: utilityFileSystem.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)) let fileSize = attr[FileAttributeKey.size] as? UInt64 ?? 0 diff --git a/iOSClient/Main/NCMainNavigationController.swift b/iOSClient/Main/NCMainNavigationController.swift index 2e4f1c4db7..ec7bfa456b 100644 --- a/iOSClient/Main/NCMainNavigationController.swift +++ b/iOSClient/Main/NCMainNavigationController.swift @@ -109,9 +109,13 @@ class NCMainNavigationController: UINavigationController, UINavigationController } NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in - self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { _ in - self.updateRightBarButtonItems() - }) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + if UIApplication.shared.applicationState == .active { + self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true, block: { _ in + self.updateRightBarButtonItems() + }) + } + } } } diff --git a/iOSClient/Main/NCMainTabBarController.swift b/iOSClient/Main/NCMainTabBarController.swift index da9e0e58ca..625a5bd8cd 100644 --- a/iOSClient/Main/NCMainTabBarController.swift +++ b/iOSClient/Main/NCMainTabBarController.swift @@ -78,7 +78,11 @@ class NCMainTabBarController: UITabBarController { } NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in - self.timerCheckServerError() + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + if UIApplication.shared.applicationState == .active { + self.timerCheckServerError() + } + } } } diff --git a/iOSClient/Networking/NCNetworkingProcess.swift b/iOSClient/Networking/NCNetworkingProcess.swift index bc7b281e0c..d4015389e7 100644 --- a/iOSClient/Networking/NCNetworkingProcess.swift +++ b/iOSClient/Networking/NCNetworkingProcess.swift @@ -53,7 +53,11 @@ class NCNetworkingProcess { } NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in - self.startTimer() + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + if UIApplication.shared.applicationState == .active { + self.startTimer() + } + } } } diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift index b470b658f4..5e94c664a6 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift @@ -598,7 +598,6 @@ extension NCViewerMediaPage: UIGestureRecognizerDelegate { } @objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) { - currentViewController.didPanWith(gestureRecognizer: gestureRecognizer) } @@ -614,7 +613,6 @@ extension NCViewerMediaPage: UIGestureRecognizerDelegate { // MARK: - Live Photo @objc func didLongpressGestureEvent(gestureRecognizer: UITapGestureRecognizer) { - if !currentViewController.metadata.isLivePhoto || currentViewController.detailView.isShown { return } if gestureRecognizer.state == .began {