Move connection policy out of ProAccess, keep terminal uploads with their session, and share question interaction and highlight editing operations. Consolidate CPU usage and settings snapshot handling, and remove obsolete terminal selection, theme helpers, and hard-coded latest-schema assertions. Fix draining connection-pool recovery and stale pane upload bindings. Keep screenshot matrices opt-in and retain behavioral migration coverage. Validation: 2468 macOS tests passed serially, 31 iOS tests passed, and both SSH forwarding regressions passed against the local OpenSSH fixture. Both app builds, Swift formatting, AppStrings, and Chinese localization checks passed. Parallel test runs still exhibit intermittent timeouts.
41 lines
1.4 KiB
Swift
41 lines
1.4 KiB
Swift
import SwiftUI
|
|
import TermindApplication
|
|
import TermindDomain
|
|
|
|
/// Editing-only projections. Reading a free value never overwrites the saved choice.
|
|
public struct MultiConnectionSettingsAccess {
|
|
public var isAllowed: Bool
|
|
private let requestAccess: () -> Void
|
|
|
|
public init(isAllowed: Bool, requestAccess: @escaping () -> Void) {
|
|
self.isAllowed = isAllowed
|
|
self.requestAccess = requestAccess
|
|
}
|
|
|
|
private var policy: MultiConnectionPolicy { .init(allowsMultipleConnections: isAllowed) }
|
|
|
|
public func strategy(for model: SFTPSettingsModel) -> Binding<SFTPConcurrencyStrategy> {
|
|
Binding(
|
|
get: { policy.sftpStrategy(model.preferences.strategy) },
|
|
set: { value in
|
|
guard isAllowed else {
|
|
if value != policy.sftpStrategy(value) { requestAccess() }
|
|
return
|
|
}
|
|
model.setStrategy(value)
|
|
})
|
|
}
|
|
|
|
public func forwardingConnections(_ saved: Binding<Int>) -> Binding<Int> {
|
|
Binding(
|
|
get: { policy.forwardingConnections(saved.wrappedValue) },
|
|
set: { value in
|
|
guard isAllowed else {
|
|
if value > policy.forwardingConnections(value) { requestAccess() }
|
|
return
|
|
}
|
|
saved.wrappedValue = policy.forwardingConnections(value)
|
|
})
|
|
}
|
|
}
|