Skip to content

Commit c6ec16e

Browse files
Version 6.1.9 (#3242)
1 parent fda9328 commit c6ec16e

File tree

124 files changed

+312
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+312
-92
lines changed

Brand/NCBrand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let userAgent: String = {
3939
var textCopyrightNextcloudiOS: String = "Nextcloud Hydrogen for iOS %@ © 2024"
4040
var textCopyrightNextcloudServer: String = "Nextcloud Server %@"
4141
var loginBaseUrl: String = "https://cloud.nextcloud.com"
42-
@objc var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com"
42+
var pushNotificationServerProxy: String = "https://push-notifications.nextcloud.com"
4343
var linkLoginHost: String = "https://nextcloud.com/install"
4444
var linkloginPreferredProviders: String = "https://nextcloud.com/signup-ios"
4545
var webLoginAutenticationProtocol: String = "nc://" // example "abc://"

File Provider Extension/FileProviderEnumerator.swift

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
3131
var serverUrl: String?
3232
let providerUtility = fileProviderUtility()
3333
let database = NCManageDatabase.shared
34-
var recordsPerPage: Int = 20
3534
var anchor: UInt64 = 0
35+
// X-NC-PAGINATE
36+
var recordsPerPage: Int = 100
37+
var paginateToken: String?
38+
var paginatedTotal: Int = 0
3639

3740
init(enumeratedItemIdentifier: NSFileProviderItemIdentifier) {
3841
self.enumeratedItemIdentifier = enumeratedItemIdentifier
@@ -82,13 +85,13 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
8285
observer.finishEnumerating(upTo: nil)
8386
return
8487
}
85-
var pageNumber = 1
88+
var pageNumber = 0
8689
if let stringPage = String(data: page.rawValue, encoding: .utf8),
8790
let intPage = Int(stringPage) {
8891
pageNumber = intPage
8992
}
9093

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

106109
if let metadatas,
107-
metadatas.count == self.recordsPerPage {
110+
isPaginated,
111+
metadatas.count == self.recordsPerPage {
108112
pageNumber += 1
109113
let providerPage = NSFileProviderPage("\(pageNumber)".data(using: .utf8)!)
110114
observer.finishEnumerating(upTo: providerPage)
@@ -157,27 +161,56 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
157161
completionHandler(NSFileProviderSyncAnchor(data!))
158162
}
159163

160-
func fetchItemsForPage(serverUrl: String, pageNumber: Int, completionHandler: @escaping (_ metadatas: Results<tableMetadata>?) -> Void) {
161-
let predicate = NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl)
164+
func fetchItemsForPage(serverUrl: String, pageNumber: Int, completion: @escaping (_ metadatas: [tableMetadata]?, _ isPaginated: Bool) -> Void) {
165+
var useFirstAsMetadataFolder: Bool = false
166+
var isPaginated: Bool = false
167+
var paginateCount = recordsPerPage
168+
if pageNumber == 0 {
169+
paginateCount += 1
170+
}
171+
var offset = pageNumber * recordsPerPage
172+
if pageNumber > 0 {
173+
offset += 1
174+
}
175+
let options = NKRequestOptions(paginate: true,
176+
paginateToken: self.paginateToken,
177+
paginateOffset: offset,
178+
paginateCount: paginateCount,
179+
queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)
180+
181+
print("PAGINATE OFFSET: \(offset) COUNT: \(paginateCount) TOTAL: \(self.paginatedTotal)")
182+
183+
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles, account: fileProviderData.shared.session.account, options: options) { _, files, responseData, error in
184+
if let headers = responseData?.response?.allHeaderFields as? [String: String] {
185+
let normalizedHeaders = Dictionary(uniqueKeysWithValues: headers.map { ($0.key.lowercased(), $0.value) })
186+
isPaginated = Bool(normalizedHeaders["x-nc-paginate"] ?? "false") ?? false
187+
self.paginateToken = normalizedHeaders["x-nc-paginate-token"]
188+
self.paginatedTotal = Int(normalizedHeaders["x-nc-paginate-total"] ?? "0") ?? 0
189+
}
162190

163-
if pageNumber == 1 {
164-
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: NCKeychain().showHiddenFiles, account: fileProviderData.shared.session.account) { _, files, _, error in
165-
if error == .success, let files {
166-
self.database.convertFilesToMetadatas(files, useFirstAsMetadataFolder: true) { metadataFolder, metadatas in
167-
/// FOLDER
191+
if error == .success, let files {
192+
if pageNumber == 0 {
193+
self.database.deleteMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl))
194+
useFirstAsMetadataFolder = true
195+
}
196+
self.database.convertFilesToMetadatas(files, useFirstAsMetadataFolder: useFirstAsMetadataFolder) { metadataFolder, metadatas in
197+
/// FOLDER
198+
if useFirstAsMetadataFolder {
168199
self.database.addMetadata(metadataFolder)
169200
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)
170-
/// FILES
171-
self.database.deleteMetadata(predicate: predicate)
172-
self.database.addMetadatas(metadatas)
173201
}
202+
/// FILES
203+
self.database.addMetadatas(metadatas)
204+
completion(metadatas, isPaginated)
205+
}
206+
} else {
207+
if isPaginated {
208+
completion(nil, isPaginated)
209+
} else {
210+
let metadatas = self.database.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", fileProviderData.shared.session.account, serverUrl))
211+
completion(metadatas, isPaginated)
174212
}
175-
let resultsMetadata = self.database.fetchPagedResults(ofType: tableMetadata.self, primaryKey: "ocId", recordsPerPage: self.recordsPerPage, pageNumber: pageNumber, filter: predicate, sortedByKeyPath: "fileName")
176-
completionHandler(resultsMetadata)
177213
}
178-
} else {
179-
let resultsMetadata = self.database.fetchPagedResults(ofType: tableMetadata.self, primaryKey: "ocId", recordsPerPage: recordsPerPage, pageNumber: pageNumber, filter: predicate, sortedByKeyPath: "fileName")
180-
completionHandler(resultsMetadata)
181214
}
182215
}
183216
}

File Provider Extension/FileProviderExtension+Thumbnail.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ extension FileProviderExtension {
3232
var counterProgress: Int64 = 0
3333

3434
for itemIdentifier in itemIdentifiers {
35-
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier), metadata.hasPreview else {
35+
guard let metadata = providerUtility.getTableMetadataFromItemIdentifier(itemIdentifier),
36+
metadata.hasPreview
37+
else {
3638
counterProgress += 1
37-
if counterProgress == progress.totalUnitCount { completionHandler(nil) }
39+
if counterProgress == progress.totalUnitCount {
40+
completionHandler(nil)
41+
}
3842
continue
3943
}
4044

4145
NextcloudKit.shared.downloadPreview(fileId: metadata.fileId,
42-
width: Int(size.width),
43-
height: Int(size.height),
46+
width: Int(NCGlobal.shared.size512.width),
47+
height: Int(NCGlobal.shared.size512.height),
4448
etag: metadata.etag,
4549
account: metadata.account) { _ in
4650
} completion: { _, _, _, _, responseData, error in
@@ -55,6 +59,7 @@ extension FileProviderExtension {
5559
}
5660
}
5761
}
62+
5863
return progress
5964
}
6065
}

Nextcloud.xcodeproj/project.pbxproj

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@
234234
F711A4EB2AF9327D00095DD8 /* UIImage+animatedGIF.m in Sources */ = {isa = PBXBuildFile; fileRef = F713FEFF2472764100214AF6 /* UIImage+animatedGIF.m */; };
235235
F711A4EF2AF932B900095DD8 /* SVGKitSwift in Frameworks */ = {isa = PBXBuildFile; productRef = F711A4EE2AF932B900095DD8 /* SVGKitSwift */; };
236236
F711D63128F44801003F43C8 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C9739428F17131002C43E2 /* IntentHandler.swift */; };
237+
F7132C722D085AD200B42D6A /* NCTermOfServiceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7132C6B2D085AD200B42D6A /* NCTermOfServiceModel.swift */; };
238+
F7132C732D085AD200B42D6A /* NCTermOfServiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7132C6C2D085AD200B42D6A /* NCTermOfServiceView.swift */; };
237239
F713FBE52C31645200F10760 /* NCNetworking+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */; };
238240
F713FBE62C31646400F10760 /* NCNetworking+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */; };
239241
F713FBE72C31646500F10760 /* NCNetworking+AsyncAwait.swift in Sources */ = {isa = PBXBuildFile; fileRef = F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */; };
@@ -1258,6 +1260,8 @@
12581260
F710D1F42405770F00A6033D /* NCViewerPDF.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCViewerPDF.swift; sourceTree = "<group>"; };
12591261
F710D2012405826100A6033D /* NCViewer+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCViewer+Menu.swift"; sourceTree = "<group>"; };
12601262
F711A4DB2AF92CAD00095DD8 /* NCUtility+Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCUtility+Date.swift"; sourceTree = "<group>"; };
1263+
F7132C6B2D085AD200B42D6A /* NCTermOfServiceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTermOfServiceModel.swift; sourceTree = "<group>"; };
1264+
F7132C6C2D085AD200B42D6A /* NCTermOfServiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTermOfServiceView.swift; sourceTree = "<group>"; };
12611265
F713FBE42C31645200F10760 /* NCNetworking+AsyncAwait.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCNetworking+AsyncAwait.swift"; sourceTree = "<group>"; };
12621266
F713FEFE2472764000214AF6 /* UIImage+animatedGIF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+animatedGIF.h"; sourceTree = "<group>"; };
12631267
F713FEFF2472764100214AF6 /* UIImage+animatedGIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+animatedGIF.m"; sourceTree = "<group>"; };
@@ -2095,6 +2099,15 @@
20952099
path = Color;
20962100
sourceTree = "<group>";
20972101
};
2102+
F7132C6D2D085AD200B42D6A /* Terms of service */ = {
2103+
isa = PBXGroup;
2104+
children = (
2105+
F7132C6B2D085AD200B42D6A /* NCTermOfServiceModel.swift */,
2106+
F7132C6C2D085AD200B42D6A /* NCTermOfServiceView.swift */,
2107+
);
2108+
path = "Terms of service";
2109+
sourceTree = "<group>";
2110+
};
20982111
F713418B2597513800768D21 /* PushNotification */ = {
20992112
isa = PBXGroup;
21002113
children = (
@@ -3091,6 +3104,7 @@
30913104
F79A65C12191D8DC00FF6DCC /* Select */,
30923105
F728CE741BF6322C00E69702 /* Share */,
30933106
F7169A161EE590930086BD69 /* Shares */,
3107+
F7132C6D2D085AD200B42D6A /* Terms of service */,
30943108
F7E9C41320F4CA870040CF18 /* Transfers */,
30953109
F78F74322163753B00C2ADAD /* Trash */,
30963110
F7EFC0CB256BF89300461AAD /* UserStatus */,
@@ -4367,6 +4381,8 @@
43674381
F7CBC1252BAC8B0000EC1D55 /* NCSectionFirstHeaderEmptyData.swift in Sources */,
43684382
F7D4BF3D2CA2E8D800A5E746 /* TOPasscodeKeypadView.m in Sources */,
43694383
F7D4BF3E2CA2E8D800A5E746 /* TOPasscodeSettingsKeypadView.m in Sources */,
4384+
F7132C722D085AD200B42D6A /* NCTermOfServiceModel.swift in Sources */,
4385+
F7132C732D085AD200B42D6A /* NCTermOfServiceView.swift in Sources */,
43704386
F7D4BF3F2CA2E8D800A5E746 /* TOPasscodeFixedInputView.m in Sources */,
43714387
F7D4BF402CA2E8D800A5E746 /* TOPasscodeButtonLabel.m in Sources */,
43724388
F7D4BF412CA2E8D800A5E746 /* TOPasscodeViewControllerAnimatedTransitioning.m in Sources */,
@@ -5487,7 +5503,7 @@
54875503
CLANG_WARN_UNREACHABLE_CODE = YES;
54885504
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
54895505
COPY_PHASE_STRIP = NO;
5490-
CURRENT_PROJECT_VERSION = 2;
5506+
CURRENT_PROJECT_VERSION = 4;
54915507
DEBUG_INFORMATION_FORMAT = dwarf;
54925508
DEVELOPMENT_TEAM = NKUJUXUJ3B;
54935509
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -5514,7 +5530,7 @@
55145530
"@executable_path/Frameworks",
55155531
"@executable_path/../../Frameworks",
55165532
);
5517-
MARKETING_VERSION = 6.1.8;
5533+
MARKETING_VERSION = 6.1.9;
55185534
ONLY_ACTIVE_ARCH = YES;
55195535
OTHER_CFLAGS = "-v";
55205536
OTHER_LDFLAGS = "";
@@ -5553,7 +5569,7 @@
55535569
CLANG_WARN_UNREACHABLE_CODE = YES;
55545570
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
55555571
COPY_PHASE_STRIP = NO;
5556-
CURRENT_PROJECT_VERSION = 2;
5572+
CURRENT_PROJECT_VERSION = 4;
55575573
DEVELOPMENT_TEAM = NKUJUXUJ3B;
55585574
ENABLE_STRICT_OBJC_MSGSEND = YES;
55595575
ENABLE_TESTABILITY = YES;
@@ -5577,7 +5593,7 @@
55775593
"@executable_path/Frameworks",
55785594
"@executable_path/../../Frameworks",
55795595
);
5580-
MARKETING_VERSION = 6.1.8;
5596+
MARKETING_VERSION = 6.1.9;
55815597
ONLY_ACTIVE_ARCH = YES;
55825598
OTHER_CFLAGS = "-v";
55835599
OTHER_LDFLAGS = "";
@@ -5852,7 +5868,7 @@
58525868
repositoryURL = "https://github.com/nextcloud/NextcloudKit";
58535869
requirement = {
58545870
kind = exactVersion;
5855-
version = 5.0.1;
5871+
version = 5.0.2;
58565872
};
58575873
};
58585874
F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

iOSClient/Account Settings/NCAccountSettingsModel.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,13 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling {
160160
}
161161

162162
/// Function to change account after 1.5 sec of change
163-
func setAccount(account: String) {
163+
func setAccount(account: String?) {
164+
guard let account
165+
else {
166+
self.tblAccount = nil
167+
self.alias = ""
168+
return
169+
}
164170
if let tableAccount = database.getTableAccount(predicate: NSPredicate(format: "account == %@", account)) {
165171
self.tblAccount = tableAccount
166172
self.alias = tableAccount.alias
@@ -170,14 +176,10 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling {
170176
/// Function to delete the current account
171177
func deleteAccount() {
172178
if let tblAccount {
173-
NCAccount().deleteAccount(tblAccount.account)
174-
if let account = database.getAllTableAccount().first?.account {
175-
NCAccount().changeAccount(account, userProfile: nil, controller: self.controller) {
176-
onViewAppear()
177-
}
178-
} else {
179+
NCAccount().deleteAccount(tblAccount.account) {
180+
let account = database.getAllTableAccount().first?.account
181+
setAccount(account: account)
179182
dismissView = true
180-
appDelegate.openLogin(selector: NCGlobal.shared.introLogin)
181183
}
182184
}
183185
}

iOSClient/Account Settings/NCAccountSettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct NCAccountSettingsView: View {
5050
Image(uiImage: avatar)
5151
.resizable()
5252
.scaledToFit()
53-
.frame(width: UIScreen.main.bounds.width, height: 75)
53+
.frame(width: UIScreen.main.bounds.width, height: 65)
5454
if let statusImage = status.statusImage {
5555
ZStack {
5656
Circle()

iOSClient/AppDelegate.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
279279
}
280280

281281
func nextcloudPushNotificationAction(data: [String: AnyObject]) {
282-
guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data),
283-
let account = data["account"] as? String
282+
guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data)
284283
else {
285284
return
286285
}
286+
let account = data["account"] as? String ?? "unavailable"
287+
let app = data["app"] as? String
287288

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

0 commit comments

Comments
 (0)