Fix XIB initialisation in LockViewController

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-07-31 18:17:54 +08:00 committed by Matthieu Gallien
parent 4dbfbc3d96
commit 616ac2e50c
2 changed files with 18 additions and 4 deletions

View file

@ -22,6 +22,10 @@ class LockViewController: NSViewController {
@IBOutlet weak var closeButton: NSButton! @IBOutlet weak var closeButton: NSButton!
@IBOutlet weak var loadingIndicator: NSProgressIndicator! @IBOutlet weak var loadingIndicator: NSProgressIndicator!
public override var nibName: NSNib.Name? {
return NSNib.Name(self.className)
}
var actionViewController: DocumentActionViewController! { var actionViewController: DocumentActionViewController! {
return parent as? DocumentActionViewController return parent as? DocumentActionViewController
} }
@ -30,22 +34,31 @@ class LockViewController: NSViewController {
self.itemIdentifiers = itemIdentifiers self.itemIdentifiers = itemIdentifiers
self.locking = locking self.locking = locking
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
guard let firstItem = itemIdentifiers.first else { guard let firstItem = itemIdentifiers.first else {
Logger.shareViewController.error("called without items") Logger.shareViewController.error("called without items")
closeAction(self) closeAction(self)
return return
} }
Logger.lockViewController.info(
"""
Locking \(self.locking ? "enabled" : "disabled", privacy: .public) for items:
\(firstItem.rawValue, privacy: .public)
"""
)
Task { Task {
await processItemIdentifier(firstItem) await processItemIdentifier(firstItem)
} }
} }
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@IBAction func closeAction(_ sender: Any) { @IBAction func closeAction(_ sender: Any) {
actionViewController.extensionContext.completeRequest() actionViewController.extensionContext.completeRequest()
} }

View file

@ -14,6 +14,7 @@
<outlet property="fileNameIcon" destination="KlP-OW-SKo" id="Dey-vA-qIG"/> <outlet property="fileNameIcon" destination="KlP-OW-SKo" id="Dey-vA-qIG"/>
<outlet property="fileNameLabel" destination="LDe-7m-hvL" id="AzB-UH-ndO"/> <outlet property="fileNameLabel" destination="LDe-7m-hvL" id="AzB-UH-ndO"/>
<outlet property="loadingIndicator" destination="UWQ-uR-PJA" id="Swv-It-LT9"/> <outlet property="loadingIndicator" destination="UWQ-uR-PJA" id="Swv-It-LT9"/>
<outlet property="view" destination="Ge9-bk-WPE" id="F9c-24-JAT"/>
</connections> </connections>
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>