Always correctly set values for all fields in File Provider sharing UI
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 23 Apr 2024 15:48:53 +0000 (23:48 +0800)
committerCamila Ayres <hello@camilasan.com>
Tue, 23 Apr 2024 18:23:19 +0000 (20:23 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift

index 995bc1f29652427aab7b3261a47c4dd246c44bdd..3e16a34ccff3d7137c0ff5bc84a1c652115dc690 100644 (file)
@@ -105,21 +105,22 @@ class ShareOptionsView: NSView {
         deleteButton.isEnabled = share.canDelete
         saveButton.isEnabled = share.canEdit
 
-        if share.canEdit {
-            setAllFields(enabled: true)
-            labelTextField.stringValue = share.label
-            uploadEditPermissionCheckbox.state = share.shareesCanEdit ? .on : .off
-            hideDownloadCheckbox.state = share.hideDownload ? .on : .off
-            passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on
-            passwordSecureField.isHidden = passwordProtectCheckbox.state == .off
-            expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on
-            expirationDatePicker.isHidden = expirationDateCheckbox.state == .off
-            noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on
-            noteTextField.isHidden = noteForRecipientCheckbox.state == .off
-        } else {
-            setAllFields(enabled: false)
-            reset()
-        }
+        setAllFields(enabled: share.canEdit)
+        reset()
+
+        shareRecipientTextField.stringValue = share.shareWithDisplayname
+        labelTextField.stringValue = share.label
+        uploadEditPermissionCheckbox.state = share.shareesCanEdit ? .on : .off
+        hideDownloadCheckbox.state = share.hideDownload ? .on : .off
+        passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on
+        passwordSecureField.isHidden = passwordProtectCheckbox.state == .off
+        passwordSecureField.stringValue = share.password
+        expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on
+        expirationDatePicker.isHidden = expirationDateCheckbox.state == .off
+        expirationDatePicker.dateValue = share.expirationDate as? Date ?? Date()
+        noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on
+        noteTextField.isHidden = noteForRecipientCheckbox.state == .off
+        noteForRecipientCheckbox.stringValue = share.note
     }
 
     private func reset() {