Allow milestones to be closed and reopened
This commit is contained in:
@@ -657,7 +657,7 @@ public protocol GotchaCoreProtocol: AnyObject, Sendable {
|
||||
|
||||
func saveIssueComment(owner: String, repository: String, number: Int64, commentId: Int64?, body: String) async throws
|
||||
|
||||
func saveMilestone(owner: String, repository: String, id: Int64?, title: String, description: String, dueDate: Int64?) async throws -> Int64
|
||||
func saveMilestone(owner: String, repository: String, id: Int64?, draft: MilestoneEditorPage) async throws -> Int64
|
||||
|
||||
func selectServer(index: UInt32) throws
|
||||
|
||||
@@ -1133,12 +1133,12 @@ open func saveIssueComment(owner: String, repository: String, number: Int64, com
|
||||
)
|
||||
}
|
||||
|
||||
open func saveMilestone(owner: String, repository: String, id: Int64?, title: String, description: String, dueDate: Int64?)async throws -> Int64 {
|
||||
open func saveMilestone(owner: String, repository: String, id: Int64?, draft: MilestoneEditorPage)async throws -> Int64 {
|
||||
return
|
||||
try await uniffiRustCallAsync(
|
||||
rustFutureFunc: {
|
||||
uniffi_gotcha_core_fn_method_gotchacore_save_milestone(
|
||||
self.uniffiCloneHandle(),FfiConverterString.lower(owner),FfiConverterString.lower(repository),FfiConverterOptionInt64.lower(id),FfiConverterString.lower(title),FfiConverterString.lower(description),FfiConverterOptionInt64.lower(dueDate)
|
||||
self.uniffiCloneHandle(),FfiConverterString.lower(owner),FfiConverterString.lower(repository),FfiConverterOptionInt64.lower(id),FfiConverterTypeMilestoneEditorPage_lower(draft)
|
||||
)
|
||||
},
|
||||
pollFunc: ffi_gotcha_core_rust_future_poll_i64,
|
||||
@@ -2571,13 +2571,15 @@ public struct MilestoneEditorPage: Equatable, Hashable {
|
||||
public var title: String
|
||||
public var description: String
|
||||
public var dueDate: Int64?
|
||||
public var closed: Bool
|
||||
|
||||
// Default memberwise initializers are never public by default, so we
|
||||
// declare one manually.
|
||||
public init(title: String, description: String, dueDate: Int64?) {
|
||||
public init(title: String, description: String, dueDate: Int64?, closed: Bool) {
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.dueDate = dueDate
|
||||
self.closed = closed
|
||||
}
|
||||
|
||||
|
||||
@@ -2598,7 +2600,8 @@ public struct FfiConverterTypeMilestoneEditorPage: FfiConverterRustBuffer {
|
||||
try MilestoneEditorPage(
|
||||
title: FfiConverterString.read(from: &buf),
|
||||
description: FfiConverterString.read(from: &buf),
|
||||
dueDate: FfiConverterOptionInt64.read(from: &buf)
|
||||
dueDate: FfiConverterOptionInt64.read(from: &buf),
|
||||
closed: FfiConverterBool.read(from: &buf)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2606,6 +2609,7 @@ public struct FfiConverterTypeMilestoneEditorPage: FfiConverterRustBuffer {
|
||||
FfiConverterString.write(value.title, into: &buf)
|
||||
FfiConverterString.write(value.description, into: &buf)
|
||||
FfiConverterOptionInt64.write(value.dueDate, into: &buf)
|
||||
FfiConverterBool.write(value.closed, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4354,7 +4358,7 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_save_issue_comment() != 58596) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_save_milestone() != 33075) {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_save_milestone() != 9828) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_select_server() != 22721) {
|
||||
|
||||
@@ -396,7 +396,7 @@ uint64_t uniffi_gotcha_core_fn_method_gotchacore_save_issue_comment(uint64_t ptr
|
||||
#endif
|
||||
#ifndef UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_SAVE_MILESTONE
|
||||
#define UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_SAVE_MILESTONE
|
||||
uint64_t uniffi_gotcha_core_fn_method_gotchacore_save_milestone(uint64_t ptr, RustBuffer owner, RustBuffer repository, RustBuffer id, RustBuffer title, RustBuffer description, RustBuffer due_date
|
||||
uint64_t uniffi_gotcha_core_fn_method_gotchacore_save_milestone(uint64_t ptr, RustBuffer owner, RustBuffer repository, RustBuffer id, RustBuffer draft
|
||||
);
|
||||
#endif
|
||||
#ifndef UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_SELECT_SERVER
|
||||
|
||||
@@ -11,6 +11,7 @@ final class MilestoneEditorViewController: UIViewController, UITextFieldDelegate
|
||||
private let stack = UIStackView()
|
||||
private let titleField = UITextField()
|
||||
private let descriptionView = UITextView()
|
||||
private let closedSwitch = UISwitch()
|
||||
private let dueSwitch = UISwitch()
|
||||
private let duePicker = UIDatePicker()
|
||||
private let spinner = UIActivityIndicatorView(style: .medium)
|
||||
@@ -88,6 +89,14 @@ final class MilestoneEditorViewController: UIViewController, UITextFieldDelegate
|
||||
descriptionView.autocapitalizationType = .sentences
|
||||
descriptionView.accessibilityLabel = "Milestone description"
|
||||
|
||||
let closedLabel = UILabel()
|
||||
closedLabel.text = "Closed"
|
||||
closedLabel.font = .preferredFont(forTextStyle: .body)
|
||||
closedLabel.adjustsFontForContentSizeCategory = true
|
||||
let closedRow = UIStackView(arrangedSubviews: [closedLabel, closedSwitch])
|
||||
closedRow.alignment = .center
|
||||
closedSwitch.accessibilityLabel = "Closed milestone"
|
||||
|
||||
let dueLabel = UILabel()
|
||||
dueLabel.text = "Due Date"
|
||||
dueLabel.font = .preferredFont(forTextStyle: .body)
|
||||
@@ -103,6 +112,7 @@ final class MilestoneEditorViewController: UIViewController, UITextFieldDelegate
|
||||
stack.addArrangedSubview(titleField)
|
||||
stack.addArrangedSubview(descriptionLabel)
|
||||
stack.addArrangedSubview(descriptionView)
|
||||
stack.addArrangedSubview(closedRow)
|
||||
stack.addArrangedSubview(dueRow)
|
||||
stack.addArrangedSubview(duePicker)
|
||||
NSLayoutConstraint.activate([
|
||||
@@ -129,6 +139,7 @@ final class MilestoneEditorViewController: UIViewController, UITextFieldDelegate
|
||||
guard !Task.isCancelled else { return }
|
||||
titleField.text = page.title
|
||||
descriptionView.text = page.description
|
||||
closedSwitch.isOn = page.closed
|
||||
if let timestamp = page.dueDate {
|
||||
dueSwitch.isOn = true
|
||||
duePicker.date = localDate(forUTCTimestamp: timestamp)
|
||||
@@ -167,9 +178,12 @@ final class MilestoneEditorViewController: UIViewController, UITextFieldDelegate
|
||||
owner: owner,
|
||||
repository: repository,
|
||||
id: id,
|
||||
title: titleField.text ?? "",
|
||||
description: descriptionView.text ?? "",
|
||||
dueDate: dueSwitch.isOn ? utcTimestamp(forLocalDate: duePicker.date) : nil
|
||||
draft: MilestoneEditorPage(
|
||||
title: titleField.text ?? "",
|
||||
description: descriptionView.text ?? "",
|
||||
dueDate: dueSwitch.isOn ? utcTimestamp(forLocalDate: duePicker.date) : nil,
|
||||
closed: closedSwitch.isOn
|
||||
)
|
||||
)
|
||||
guard !Task.isCancelled else { return }
|
||||
saved(id)
|
||||
|
||||
Reference in New Issue
Block a user