Skip to content

Commit

Permalink
Version 6.1.9 (#3242)
Browse files Browse the repository at this point in the history
  • Loading branch information
marinofaggiana authored Dec 16, 2024
1 parent fda9328 commit c6ec16e
Show file tree
Hide file tree
Showing 124 changed files with 312 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Brand/NCBrand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let userAgent: String = {
var textCopyrightNextcloudiOS: String = "Nextcloud Hydrogen for iOS %@ © 2024"
var textCopyrightNextcloudServer: String = "Nextcloud Server %@"
var loginBaseUrl: String = "https://cloud.nextcloud.com"
@objc var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com"
var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com"
var linkLoginHost: String = "https://nextcloud.com/install"
var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios"
var webLoginAutenticationProtocol: String = "nc://" // example "abc://"
Expand Down
71 changes: 52 additions & 19 deletions File Provider Extension/FileProviderEnumerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
var serverUrl: String?
let providerUtility = fileProviderUtility()
let database = NCManageDatabase.shared
var recordsPerPage: Int = 20
var anchor: UInt64 = 0
// X-NC-PAGINATE
var recordsPerPage: Int = 100
var paginateToken: String?
var paginatedTotal: Int = 0

init(enumeratedItemIdentifier: NSFileProviderItemIdentifier) {
self.enumeratedItemIdentifier = enumeratedItemIdentifier
Expand Down Expand Up @@ -82,13 +85,13 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
observer.finishEnumerating(upTo: nil)
return
}
var pageNumber = 1
var pageNumber = 0
if let stringPage = String(data: page.rawValue, encoding: .utf8),
let intPage = Int(stringPage) {
pageNumber = intPage
}

self.fetchItemsForPage(serverUrl: serverUrl, pageNumber: pageNumber) { metadatas in
self.fetchItemsForPage(serverUrl: serverUrl, pageNumber: pageNumber) { metadatas, isPaginated in
if let metadatas {
for metadata in metadatas {
if metadata.e2eEncrypted || (!metadata.session.isEmpty && metadata.session != NCNetworking.shared.sessionUploadBackgroundExt) {
Expand All @@ -104,7 +107,8 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
observer.didEnumerate(items)

if let metadatas,
metadatas.count == self.recordsPerPage {
isPaginated,
metadatas.count == self.recordsPerPage {
pageNumber += 1
let providerPage = NSFileProviderPage("\(pageNumber)".data(using: .utf8)!)

Check warning on line 113 in File Provider Extension/FileProviderEnumerator.swift

View workflow job for this annotation

GitHub Actions / Lint

Non-optional String -> Data Conversion Violation: Prefer non-optional `Data(_:)` initializer when converting `String` to `Data` (non_optional_string_data_conversion)
observer.finishEnumerating(upTo: providerPage)
Expand Down Expand Up @@ -157,27 +161,56 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
completionHandler(NSFileProviderSyncAnchor(data!))
}

func fetchItemsForPage(serverUrl: String, pageNumber: Int, completionHandler: @escaping (_ metadatas: Results<tableMetadata>?) -> Void) {
let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl)
func fetchItemsForPage(serverUrl: String, pageNumber: Int, completion: @escaping (_ metadatas: [tableMetadata]?, _ isPaginated: Bool) -> Void) {
var useFirstAsMetadataFolder: Bool = false
var isPaginated: Bool = false
var paginateCount = recordsPerPage
if pageNumber == 0 {
paginateCount += 1
}
var offset = pageNumber * recordsPerPage
if pageNumber > 0 {
offset += 1
}
let options = NKRequestOptions(paginate: true,
paginateToken: self.paginateToken,
paginateOffset: offset,
paginateCount: paginateCount,
queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)

print("PAGINATE OFFSET: \(offset) COUNT: \(paginateCount) TOTAL: \(self.paginatedTotal)")

NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles, account: fileProviderData.shared.session.account, options: options) { _, files, responseData, error in
if let headers = responseData?.response?.allHeaderFields as? [String: String] {
let normalizedHeaders = Dictionary(uniqueKeysWithValues: headers.map { ($0.key.lowercased(), $0.value) })
isPaginated = Bool(normalizedHeaders["x-nc-paginate"] ?? "false") ?? false
self.paginateToken = normalizedHeaders["x-nc-paginate-token"]
self.paginatedTotal = Int(normalizedHeaders["x-nc-paginate-total"] ?? "0") ?? 0
}

if pageNumber == 1 {
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles, account: fileProviderData.shared.session.account) { _, files, _, error in
if error == .success, let files {
self.database.convertFilesToMetadatas(files, useFirstAsMetadataFolder: true) { metadataFolder, metadatas in
/// FOLDER
if error == .success, let files {
if pageNumber == 0 {
self.database.deleteMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl))
useFirstAsMetadataFolder = true
}
self.database.convertFilesToMetadatas(files, useFirstAsMetadataFolder: useFirstAsMetadataFolder) { metadataFolder, metadatas in
/// FOLDER
if useFirstAsMetadataFolder {
self.database.addMetadata(metadataFolder)
self.database.addDirectory(e2eEncrypted: metadataFolder.e2eEncrypted, favorite: metadataFolder.favorite, ocId: metadataFolder.ocId, fileId: metadataFolder.fileId, etag: metadataFolder.etag, permissions: metadataFolder.permissions, richWorkspace: metadataFolder.richWorkspace, serverUrl: serverUrl, account: metadataFolder.account)
/// FILES
self.database.deleteMetadata(predicate: predicate)
self.database.addMetadatas(metadatas)
}
/// FILES
self.database.addMetadatas(metadatas)
completion(metadatas, isPaginated)
}
} else {
if isPaginated {
completion(nil, isPaginated)
} else {
let metadatas = self.database.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl))
completion(metadatas, isPaginated)
}
let resultsMetadata = self.database.fetchPagedResults(ofType: tableMetadata.self, primaryKey: "ocId", recordsPerPage: self.recordsPerPage, pageNumber: pageNumber, filter: predicate, sortedByKeyPath: "fileName")
completionHandler(resultsMetadata)
}
} else {
let resultsMetadata = self.database.fetchPagedResults(ofType: tableMetadata.self, primaryKey: "ocId", recordsPerPage: recordsPerPage, pageNumber: pageNumber, filter: predicate, sortedByKeyPath: "fileName")
completionHandler(resultsMetadata)
}
}
}
13 changes: 9 additions & 4 deletions File Provider Extension/FileProviderExtension+Thumbnail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ extension FileProviderExtension {
var counterProgress: Int64 = 0

for itemIdentifier in itemIdentifiers {
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier), metadata.hasPreview else {
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier),
metadata.hasPreview
else {
counterProgress += 1
if counterProgress == progress.totalUnitCount { completionHandler(nil) }
if counterProgress == progress.totalUnitCount {
completionHandler(nil)
}
continue
}

NextcloudKit.shared.downloadPreview(fileId: metadata.fileId,
width: Int(size.width),
height: Int(size.height),
width: Int(NCGlobal.shared.size512.width),
height: Int(NCGlobal.shared.size512.height),
etag: metadata.etag,
account: metadata.account) { _ in
} completion: { _, _, _, _, responseData, error in
Expand All @@ -55,6 +59,7 @@ extension FileProviderExtension {
}
}
}

return progress
}
}
26 changes: 21 additions & 5 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
F711A4EB2AF9327D00095DD8 /* UIImage+animatedGIF.m in Sources */ = {isa = PBXBuildFile; fileRef = F713FEFF2472764100214AF6 /* UIImage+animatedGIF.m */; };
F711A4EF2AF932B900095DD8 /* SVGKitSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F711A4EE2AF932B900095DD8 /* SVGKitSwift */; };
F711D63128F44801003F43C8 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C9739428F17131002C43E2 /* IntentHandler.swift */; };
F7132C722D085AD200B42D6A /* NCTermOfServiceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7132C6B2D085AD200B42D6A /* NCTermOfServiceModel.swift */; };
F7132C732D085AD200B42D6A /* NCTermOfServiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7132C6C2D085AD200B42D6A /* NCTermOfServiceView.swift */; };
F713FBE52C31645200F10760 /* NCNetworking+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */; };
F713FBE62C31646400F10760 /* NCNetworking+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */; };
F713FBE72C31646500F10760 /* NCNetworking+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */; };
Expand Down Expand Up @@ -1258,6 +1260,8 @@
F710D1F42405770F00A6033D /* NCViewerPDF.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerPDF.swift; sourceTree = "<group>"; };
F710D2012405826100A6033D /* NCViewer+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCViewer+Menu.swift"; sourceTree = "<group>"; };
F711A4DB2AF92CAD00095DD8 /* NCUtility+Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCUtility+Date.swift"; sourceTree = "<group>"; };
F7132C6B2D085AD200B42D6A /* NCTermOfServiceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTermOfServiceModel.swift; sourceTree = "<group>"; };
F7132C6C2D085AD200B42D6A /* NCTermOfServiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTermOfServiceView.swift; sourceTree = "<group>"; };
F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCNetworking+AsyncAwait.swift"; sourceTree = "<group>"; };
F713FEFE2472764000214AF6 /* UIImage+animatedGIF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+animatedGIF.h"; sourceTree = "<group>"; };
F713FEFF2472764100214AF6 /* UIImage+animatedGIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+animatedGIF.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2095,6 +2099,15 @@
path = Color;
sourceTree = "<group>";
};
F7132C6D2D085AD200B42D6A /* Terms of service */ = {
isa = PBXGroup;
children = (
F7132C6B2D085AD200B42D6A /* NCTermOfServiceModel.swift */,
F7132C6C2D085AD200B42D6A /* NCTermOfServiceView.swift */,
);
path = "Terms of service";
sourceTree = "<group>";
};
F713418B2597513800768D21 /* PushNotification */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3091,6 +3104,7 @@
F79A65C12191D8DC00FF6DCC /* Select */,
F728CE741BF6322C00E69702 /* Share */,
F7169A161EE590930086BD69 /* Shares */,
F7132C6D2D085AD200B42D6A /* Terms of service */,
F7E9C41320F4CA870040CF18 /* Transfers */,
F78F74322163753B00C2ADAD /* Trash */,
F7EFC0CB256BF89300461AAD /* UserStatus */,
Expand Down Expand Up @@ -4367,6 +4381,8 @@
F7CBC1252BAC8B0000EC1D55 /* NCSectionFirstHeaderEmptyData.swift in Sources */,
F7D4BF3D2CA2E8D800A5E746 /* TOPasscodeKeypadView.m in Sources */,
F7D4BF3E2CA2E8D800A5E746 /* TOPasscodeSettingsKeypadView.m in Sources */,
F7132C722D085AD200B42D6A /* NCTermOfServiceModel.swift in Sources */,
F7132C732D085AD200B42D6A /* NCTermOfServiceView.swift in Sources */,
F7D4BF3F2CA2E8D800A5E746 /* TOPasscodeFixedInputView.m in Sources */,
F7D4BF402CA2E8D800A5E746 /* TOPasscodeButtonLabel.m in Sources */,
F7D4BF412CA2E8D800A5E746 /* TOPasscodeViewControllerAnimatedTransitioning.m in Sources */,
Expand Down Expand Up @@ -5487,7 +5503,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -5514,7 +5530,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.1.8;
MARKETING_VERSION = 6.1.9;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-v";
OTHER_LDFLAGS = "";
Expand Down Expand Up @@ -5553,7 +5569,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_TEAM = NKUJUXUJ3B;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -5577,7 +5593,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 6.1.8;
MARKETING_VERSION = 6.1.9;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-v";
OTHER_LDFLAGS = "";
Expand Down Expand Up @@ -5852,7 +5868,7 @@
repositoryURL = "https://github.com/nextcloud/NextcloudKit";
requirement = {
kind = exactVersion;
version = 5.0.1;
version = 5.0.2;
};
};
F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
Expand Down
18 changes: 10 additions & 8 deletions iOSClient/Account Settings/NCAccountSettingsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling {
}

/// Function to change account after 1.5 sec of change
func setAccount(account: String) {
func setAccount(account: String?) {
guard let account
else {
self.tblAccount = nil
self.alias = ""
return
}
if let tableAccount = database.getTableAccount(predicate: NSPredicate(format: "account == %@", account)) {
self.tblAccount = tableAccount
self.alias = tableAccount.alias
Expand All @@ -170,14 +176,10 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling {
/// Function to delete the current account
func deleteAccount() {
if let tblAccount {
NCAccount().deleteAccount(tblAccount.account)
if let account = database.getAllTableAccount().first?.account {
NCAccount().changeAccount(account, userProfile: nil, controller: self.controller) {
onViewAppear()
}
} else {
NCAccount().deleteAccount(tblAccount.account) {
let account = database.getAllTableAccount().first?.account
setAccount(account: account)
dismissView = true
appDelegate.openLogin(selector: NCGlobal.shared.introLogin)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Account Settings/NCAccountSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct NCAccountSettingsView: View {
Image(uiImage: avatar)
.resizable()
.scaledToFit()
.frame(width: UIScreen.main.bounds.width, height: 75)
.frame(width: UIScreen.main.bounds.width, height: 65)
if let statusImage = status.statusImage {
ZStack {
Circle()
Expand Down
9 changes: 6 additions & 3 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}

func nextcloudPushNotificationAction(data: [String: AnyObject]) {
guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data),
let account = data["account"] as? String
guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data)
else {
return
}
let account = data["account"] as? String ?? "unavailable"
let app = data["app"] as? String

func openNotification(controller: NCMainTabBarController) {
if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
if app == NCGlobal.shared.termsOfServiceName {
NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterGetServerData, second: 0.5)
} else if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
viewController.session = NCSession.shared.getSession(account: account)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
let navigationController = UINavigationController(rootViewController: viewController)
Expand Down
Loading

0 comments on commit c6ec16e

Please sign in to comment.