mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 14:05:58 +03:00
Fix options view disappearing when clicking create button in share view controller
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
d2242ea9a4
commit
bab3b4181c
4 changed files with 22 additions and 12 deletions
|
@ -274,7 +274,7 @@ class ShareOptionsView: NSView {
|
||||||
dataSource.uiDelegate?.showError("Error creating: \(error.errorDescription)")
|
dataSource.uiDelegate?.showError("Error creating: \(error.errorDescription)")
|
||||||
setAllFields(enabled: true)
|
setAllFields(enabled: true)
|
||||||
} else {
|
} else {
|
||||||
dataSource.uiDelegate?.hideOptions()
|
dataSource.uiDelegate?.hideOptions(self)
|
||||||
await dataSource.reload()
|
await dataSource.reload()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -306,7 +306,7 @@ class ShareOptionsView: NSView {
|
||||||
dataSource?.uiDelegate?.showError("Error updating share: \(error.errorDescription)")
|
dataSource?.uiDelegate?.showError("Error updating share: \(error.errorDescription)")
|
||||||
setAllFields(enabled: true)
|
setAllFields(enabled: true)
|
||||||
} else {
|
} else {
|
||||||
dataSource?.uiDelegate?.hideOptions()
|
dataSource?.uiDelegate?.hideOptions(self)
|
||||||
await dataSource?.reload()
|
await dataSource?.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ class ShareOptionsView: NSView {
|
||||||
@IBAction func delete(_ sender: Any) {
|
@IBAction func delete(_ sender: Any) {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
guard !createMode else {
|
guard !createMode else {
|
||||||
dataSource?.uiDelegate?.hideOptions()
|
dataSource?.uiDelegate?.hideOptions(self)
|
||||||
reset()
|
reset()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource, NSTableViewDele
|
||||||
|
|
||||||
@objc func tableViewSelectionDidChange(_ notification: Notification) {
|
@objc func tableViewSelectionDidChange(_ notification: Notification) {
|
||||||
guard let selectedRow = sharesTableView?.selectedRow, selectedRow >= 0 else {
|
guard let selectedRow = sharesTableView?.selectedRow, selectedRow >= 0 else {
|
||||||
Task { @MainActor in uiDelegate?.hideOptions() }
|
Task { @MainActor in uiDelegate?.hideOptions(self) }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let share = shares[selectedRow]
|
let share = shares[selectedRow]
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
dismissError(self)
|
dismissError(self)
|
||||||
hideOptions()
|
hideOptions(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func closeAction(_ sender: Any) {
|
@IBAction func closeAction(_ sender: Any) {
|
||||||
|
@ -111,11 +111,13 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func createShare(_ sender: Any) {
|
@IBAction func createShare(_ sender: Any) {
|
||||||
tableView.deselectAll(self)
|
|
||||||
optionsView.createMode = true
|
optionsView.createMode = true
|
||||||
|
tableView.deselectAll(self)
|
||||||
|
if !splitView.arrangedSubviews.contains(optionsView) {
|
||||||
splitView.addArrangedSubview(optionsView)
|
splitView.addArrangedSubview(optionsView)
|
||||||
optionsView.isHidden = false
|
optionsView.isHidden = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func fetchStarted() {
|
func fetchStarted() {
|
||||||
loadingEffectView.isHidden = false
|
loadingEffectView.isHidden = false
|
||||||
|
@ -127,17 +129,25 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
|
||||||
loadingIndicator.stopAnimation(self)
|
loadingIndicator.stopAnimation(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func hideOptions() {
|
func hideOptions(_ sender: Any) {
|
||||||
|
if sender as? ShareTableViewDataSource == shareDataSource, optionsView.createMode {
|
||||||
|
// Do not hide options if the table view has had everything deselected when we set the
|
||||||
|
// options view to be in create mode
|
||||||
|
return
|
||||||
|
}
|
||||||
splitView.removeArrangedSubview(optionsView)
|
splitView.removeArrangedSubview(optionsView)
|
||||||
optionsView.isHidden = true
|
optionsView.isHidden = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func showOptions(share: NKShare) {
|
func showOptions(share: NKShare) {
|
||||||
guard let kit = shareDataSource.kit else { return }
|
guard let kit = shareDataSource.kit else { return }
|
||||||
optionsView.controller = ShareController(share: share, kit: kit)
|
optionsView.controller = ShareController(share: share, kit: kit)
|
||||||
|
if !splitView.arrangedSubviews.contains(optionsView) {
|
||||||
splitView.addArrangedSubview(optionsView)
|
splitView.addArrangedSubview(optionsView)
|
||||||
optionsView.isHidden = false
|
optionsView.isHidden = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func showError(_ errorString: String) {
|
func showError(_ errorString: String) {
|
||||||
errorMessageStackView.isHidden = false
|
errorMessageStackView.isHidden = false
|
||||||
|
|
|
@ -11,7 +11,7 @@ import NextcloudKit
|
||||||
protocol ShareViewDataSourceUIDelegate {
|
protocol ShareViewDataSourceUIDelegate {
|
||||||
func fetchStarted()
|
func fetchStarted()
|
||||||
func fetchFinished()
|
func fetchFinished()
|
||||||
func hideOptions()
|
func hideOptions(_ sender: Any)
|
||||||
func showOptions(share: NKShare)
|
func showOptions(share: NKShare)
|
||||||
func showError(_ errorString: String)
|
func showError(_ errorString: String)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue