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

Improvements code #3370

Merged
merged 2 commits into from
Mar 22, 2025
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
4 changes: 2 additions & 2 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions iOSClient/Main/NCActionCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions iOSClient/Main/NCMainNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion iOSClient/Main/NCMainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion iOSClient/Networking/NCNetworkingProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ extension NCViewerMediaPage: UIGestureRecognizerDelegate {
}

@objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) {

currentViewController.didPanWith(gestureRecognizer: gestureRecognizer)
}

Expand All @@ -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 {
Expand Down
Loading