Skip to content
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
2 changes: 1 addition & 1 deletion iOSClient/Share/Advanced/NCShareDateCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NCShareDateCell: UITableViewCell {
super.init(style: .value1, reuseIdentifier: "shareExpDate")

picker.datePickerMode = .date
picker.minimumDate = Date()
picker.minimumDate = Calendar.current.date(byAdding: .day, value: 1, to: Date())
picker.preferredDatePickerStyle = .wheels
picker.action(for: .valueChanged) { datePicker in
guard let datePicker = datePicker as? UIDatePicker else { return }
Expand Down
43 changes: 22 additions & 21 deletions iOSClient/Share/NCShareNetworking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,20 @@ class NCShareNetworking: NSObject {
}
}

func createShare(_ template: Shareable, downloadLimit: DownloadLimitViewModel) {
// NOTE: Permissions don't work for creating with file drop!
// https://github.com/nextcloud/server/issues/17504

func createShare(_ shareable: Shareable, downloadLimit: DownloadLimitViewModel) {
NCActivityIndicator.shared.start(backgroundView: view)
let filenamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, session: session)
let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities()

NextcloudKit.shared.createShare(path: filenamePath,
shareType: template.shareType,
shareWith: template.shareWith,
shareType: shareable.shareType,
shareWith: shareable.shareWith,
publicUpload: false,
note: template.note,
note: shareable.note,
hideDownload: false,
password: template.password,
permissions: template.permissions,
attributes: template.attributes,
password: shareable.password,
permissions: shareable.permissions,
attributes: shareable.attributes,
account: metadata.account) { task in
Task {
let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: self.metadata.account,
Expand All @@ -142,16 +139,18 @@ class NCShareNetworking: NSObject {
NCActivityIndicator.shared.stop()

if error == .success, let share = share {
template.idShare = share.idShare
shareable.idShare = share.idShare
let home = self.utilityFileSystem.getHomeServer(session: self.session)
self.database.addShare(account: self.metadata.account, home: home, shares: [share])

if template.hasChanges(comparedTo: share) {
self.updateShare(template, downloadLimit: downloadLimit)
if shareable.hasChanges(comparedTo: share) {
self.updateShare(shareable, downloadLimit: downloadLimit)
// Download limit update should happen implicitly on share update.
} else {
if case let .limited(limit, _) = downloadLimit,
capabilities.fileSharingDownloadLimit {
capabilities.fileSharingDownloadLimit,
shareable.shareType == NCShareCommon.shareTypeLink,
shareable.itemType == NCShareCommon.itemTypeFile {
self.setShareDownloadLimit(limit, token: share.token)
}
}
Expand Down Expand Up @@ -196,12 +195,12 @@ class NCShareNetworking: NSObject {
}
}

func updateShare(_ option: Shareable, downloadLimit: DownloadLimitViewModel) {
func updateShare(_ shareable: Shareable, downloadLimit: DownloadLimitViewModel) {
NCActivityIndicator.shared.start(backgroundView: view)
NextcloudKit.shared.updateShare(idShare: option.idShare, password: option.password, expireDate: option.formattedDateString, permissions: option.permissions, note: option.note, label: option.label, hideDownload: option.hideDownload, attributes: option.attributes, account: metadata.account) { task in
NextcloudKit.shared.updateShare(idShare: shareable.idShare, password: shareable.password, expireDate: shareable.formattedDateString, permissions: shareable.permissions, note: shareable.note, label: shareable.label, hideDownload: shareable.hideDownload, attributes: shareable.attributes, account: metadata.account) { task in
Task {
let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: self.metadata.account,
path: "_\(option.idShare)",
path: "_\(shareable.idShare)",
name: "updateShare")
await NCNetworking.shared.networkingTasks.track(identifier: identifier, task: task)
}
Expand All @@ -215,7 +214,9 @@ class NCShareNetworking: NSObject {
self.database.addShare(account: self.metadata.account, home: home, shares: [share])
self.delegate?.readShareCompleted()

if capabilities.fileSharingDownloadLimit {
if capabilities.fileSharingDownloadLimit,
shareable.shareType == NCShareCommon.shareTypeLink,
shareable.itemType == NCShareCommon.itemTypeFile {
if case let .limited(limit, _) = downloadLimit {
self.setShareDownloadLimit(limit, token: share.token)
} else {
Expand All @@ -230,7 +231,7 @@ class NCShareNetworking: NSObject {
}
} else {
NCContentPresenter().showError(error: error)
self.delegate?.updateShareWithError(idShare: option.idShare)
self.delegate?.updateShareWithError(idShare: shareable.idShare)
}
}
}
Expand Down Expand Up @@ -264,7 +265,7 @@ class NCShareNetworking: NSObject {
func removeShareDownloadLimit(token: String) {
let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities()

if !capabilities.fileSharingDownloadLimit {
if !capabilities.fileSharingDownloadLimit || token.isEmpty {
return
}

Expand All @@ -289,7 +290,7 @@ class NCShareNetworking: NSObject {
func setShareDownloadLimit(_ limit: Int, token: String) {
let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities()

if !capabilities.fileSharingDownloadLimit {
if !capabilities.fileSharingDownloadLimit || token.isEmpty {
return
}

Expand Down
Loading