Scope repository favorites by pane
This commit is contained in:
@@ -647,7 +647,7 @@ public protocol GotchaCoreProtocol: AnyObject, Sendable {
|
||||
|
||||
func pulls(page: UInt32) async throws -> PullListPage
|
||||
|
||||
func repositories(page: UInt32) async throws -> RepositoryListPage
|
||||
func repositories(page: UInt32, pane: RepositoryPane) async throws -> RepositoryListPage
|
||||
|
||||
func repositoryContents(owner: String, repository: String, path: String) async throws -> [RepositoryContentRow]
|
||||
|
||||
@@ -677,7 +677,7 @@ public protocol GotchaCoreProtocol: AnyObject, Sendable {
|
||||
|
||||
func startupError() -> String?
|
||||
|
||||
func toggleFavorite(owner: String, repository: String) throws -> [RepositoryRow]
|
||||
func toggleFavorite(owner: String, repository: String, pane: RepositoryPane) throws -> [RepositoryRow]
|
||||
|
||||
}
|
||||
open class GotchaCore: GotchaCoreProtocol, @unchecked Sendable {
|
||||
@@ -1053,12 +1053,12 @@ open func pulls(page: UInt32)async throws -> PullListPage {
|
||||
)
|
||||
}
|
||||
|
||||
open func repositories(page: UInt32)async throws -> RepositoryListPage {
|
||||
open func repositories(page: UInt32, pane: RepositoryPane)async throws -> RepositoryListPage {
|
||||
return
|
||||
try await uniffiRustCallAsync(
|
||||
rustFutureFunc: {
|
||||
uniffi_gotcha_core_fn_method_gotchacore_repositories(
|
||||
self.uniffiCloneHandle(),FfiConverterUInt32.lower(page)
|
||||
self.uniffiCloneHandle(),FfiConverterUInt32.lower(page),FfiConverterTypeRepositoryPane_lower(pane)
|
||||
)
|
||||
},
|
||||
pollFunc: ffi_gotcha_core_rust_future_poll_rust_buffer,
|
||||
@@ -1233,13 +1233,14 @@ open func startupError() -> String? {
|
||||
})
|
||||
}
|
||||
|
||||
open func toggleFavorite(owner: String, repository: String)throws -> [RepositoryRow] {
|
||||
open func toggleFavorite(owner: String, repository: String, pane: RepositoryPane)throws -> [RepositoryRow] {
|
||||
return try FfiConverterSequenceTypeRepositoryRow.lift(try rustCallWithError(FfiConverterTypeGotchaError_lift) {
|
||||
uniffiCallStatus in
|
||||
uniffi_gotcha_core_fn_method_gotchacore_toggle_favorite(
|
||||
self.uniffiCloneHandle(),
|
||||
FfiConverterString.lower(owner),
|
||||
FfiConverterString.lower(repository),uniffiCallStatus
|
||||
FfiConverterString.lower(repository),
|
||||
FfiConverterTypeRepositoryPane_lower(pane),uniffiCallStatus
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -3443,6 +3444,79 @@ public func FfiConverterTypeHomeActivityFilter_lower(_ value: HomeActivityFilter
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public enum RepositoryPane: Equatable, Hashable {
|
||||
|
||||
case issues
|
||||
case commits
|
||||
case milestones
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if compiler(>=6)
|
||||
extension RepositoryPane: Sendable {}
|
||||
#endif
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public struct FfiConverterTypeRepositoryPane: FfiConverterRustBuffer {
|
||||
typealias SwiftType = RepositoryPane
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RepositoryPane {
|
||||
let variant: Int32 = try readInt(&buf)
|
||||
switch variant {
|
||||
|
||||
case 1: return .issues
|
||||
|
||||
case 2: return .commits
|
||||
|
||||
case 3: return .milestones
|
||||
|
||||
default: throw UniffiInternalError.unexpectedEnumCase
|
||||
}
|
||||
}
|
||||
|
||||
public static func write(_ value: RepositoryPane, into buf: inout [UInt8]) {
|
||||
switch value {
|
||||
|
||||
|
||||
case .issues:
|
||||
writeInt(&buf, Int32(1))
|
||||
|
||||
|
||||
case .commits:
|
||||
writeInt(&buf, Int32(2))
|
||||
|
||||
|
||||
case .milestones:
|
||||
writeInt(&buf, Int32(3))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeRepositoryPane_lift(_ buf: RustBuffer) throws -> RepositoryPane {
|
||||
return try FfiConverterTypeRepositoryPane.lift(buf)
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeRepositoryPane_lower(_ value: RepositoryPane) -> RustBuffer {
|
||||
return FfiConverterTypeRepositoryPane.lower(value)
|
||||
}
|
||||
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
@@ -4094,7 +4168,7 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_pulls() != 37027) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_repositories() != 31164) {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_repositories() != 4035) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_repository_contents() != 8454) {
|
||||
@@ -4139,7 +4213,7 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_startup_error() != 56765) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_toggle_favorite() != 26694) {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_toggle_favorite() != 24958) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_constructor_gotchacore_new() != 35775) {
|
||||
|
||||
@@ -371,7 +371,7 @@ uint64_t uniffi_gotcha_core_fn_method_gotchacore_pulls(uint64_t ptr, uint32_t pa
|
||||
#endif
|
||||
#ifndef UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_REPOSITORIES
|
||||
#define UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_REPOSITORIES
|
||||
uint64_t uniffi_gotcha_core_fn_method_gotchacore_repositories(uint64_t ptr, uint32_t page
|
||||
uint64_t uniffi_gotcha_core_fn_method_gotchacore_repositories(uint64_t ptr, uint32_t page, RustBuffer pane
|
||||
);
|
||||
#endif
|
||||
#ifndef UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_REPOSITORY_CONTENTS
|
||||
@@ -446,7 +446,7 @@ RustBuffer uniffi_gotcha_core_fn_method_gotchacore_startup_error(uint64_t ptr, R
|
||||
#endif
|
||||
#ifndef UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_TOGGLE_FAVORITE
|
||||
#define UNIFFI_FFIDEF_UNIFFI_GOTCHA_CORE_FN_METHOD_GOTCHACORE_TOGGLE_FAVORITE
|
||||
RustBuffer uniffi_gotcha_core_fn_method_gotchacore_toggle_favorite(uint64_t ptr, RustBuffer owner, RustBuffer repository, RustCallStatus *_Nonnull out_status
|
||||
RustBuffer uniffi_gotcha_core_fn_method_gotchacore_toggle_favorite(uint64_t ptr, RustBuffer owner, RustBuffer repository, RustBuffer pane, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
#endif
|
||||
#ifndef UNIFFI_FFIDEF_FFI_GOTCHA_CORE_RUSTBUFFER_ALLOC
|
||||
|
||||
@@ -125,7 +125,7 @@ final class AppContext {
|
||||
UIImage(systemName: name)
|
||||
}
|
||||
|
||||
private func repositoryRoot(mode: RepositoryMode) -> UIViewController {
|
||||
private func repositoryRoot(mode: RepositoryPane) -> UIViewController {
|
||||
if core.activeServerIndex() == nil {
|
||||
return ServersViewController(context: self)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import UIKit
|
||||
|
||||
enum RepositoryMode {
|
||||
case issues
|
||||
case commits
|
||||
case milestones
|
||||
}
|
||||
|
||||
@MainActor
|
||||
final class ServersViewController: UITableViewController {
|
||||
private let context: AppContext
|
||||
@@ -186,11 +180,11 @@ final class AddServerViewController: UITableViewController, UITextFieldDelegate
|
||||
@MainActor
|
||||
final class RepositoriesViewController: RefreshingTableViewController {
|
||||
private let context: AppContext
|
||||
private let mode: RepositoryMode
|
||||
private let mode: RepositoryPane
|
||||
private var rows: [RepositoryRow] = []
|
||||
private var currentPage: UInt32 = 0
|
||||
|
||||
init(context: AppContext, mode: RepositoryMode) {
|
||||
init(context: AppContext, mode: RepositoryPane) {
|
||||
self.context = context
|
||||
self.mode = mode
|
||||
super.init()
|
||||
@@ -231,7 +225,7 @@ final class RepositoriesViewController: RefreshingTableViewController {
|
||||
loadingTask?.cancel()
|
||||
loadingTask = Task {
|
||||
do {
|
||||
let result = try await context.core.repositories(page: page)
|
||||
let result = try await context.core.repositories(page: page, pane: mode)
|
||||
rows = result.rows
|
||||
currentPage = page
|
||||
finishPagination(hasMore: result.hasMore)
|
||||
@@ -307,7 +301,11 @@ final class RepositoriesViewController: RefreshingTableViewController {
|
||||
|
||||
private func toggleFavorite(_ row: RepositoryRow) {
|
||||
do {
|
||||
rows = try context.core.toggleFavorite(owner: row.owner, repository: row.name)
|
||||
rows = try context.core.toggleFavorite(
|
||||
owner: row.owner,
|
||||
repository: row.name,
|
||||
pane: mode
|
||||
)
|
||||
tableView.reloadData()
|
||||
} catch {
|
||||
show(error: error)
|
||||
|
||||
Reference in New Issue
Block a user