fix(macos): bridge wizard option values
This commit is contained in:
@@ -7,17 +7,22 @@ import SwiftUI
|
|||||||
private let onboardingWizardLogger = Logger(subsystem: "com.clawdis", category: "onboarding.wizard")
|
private let onboardingWizardLogger = Logger(subsystem: "com.clawdis", category: "onboarding.wizard")
|
||||||
|
|
||||||
// MARK: - Swift 6 AnyCodable Bridging Helpers
|
// MARK: - Swift 6 AnyCodable Bridging Helpers
|
||||||
// These helpers bridge between ClawdisProtocol.AnyCodable and the local module
|
// Bridge between ClawdisProtocol.AnyCodable and the local module to avoid
|
||||||
// to avoid Swift 6 strict concurrency type conflicts.
|
// Swift 6 strict concurrency type conflicts.
|
||||||
|
|
||||||
private typealias ProtocolAnyCodable = ClawdisProtocol.AnyCodable
|
private typealias ProtocolAnyCodable = ClawdisProtocol.AnyCodable
|
||||||
|
|
||||||
private func bridgeToProtocol(_ value: Any) -> ProtocolAnyCodable {
|
private func bridgeToLocal(_ value: ProtocolAnyCodable) -> AnyCodable {
|
||||||
ProtocolAnyCodable(value)
|
if let data = try? JSONEncoder().encode(value),
|
||||||
|
let decoded = try? JSONDecoder().decode(AnyCodable.self, from: data)
|
||||||
|
{
|
||||||
|
return decoded
|
||||||
|
}
|
||||||
|
return AnyCodable(value.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func bridgeDict(_ dict: [String: Any]) -> [String: ProtocolAnyCodable] {
|
private func bridgeToLocal(_ value: ProtocolAnyCodable?) -> AnyCodable? {
|
||||||
dict.mapValues { ProtocolAnyCodable($0) }
|
value.map(bridgeToLocal)
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@@ -299,11 +304,11 @@ struct OnboardingWizardStepView: View {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let option = optionItems[selectedIndex].option
|
let option = optionItems[selectedIndex].option
|
||||||
onSubmit(option.value ?? AnyCodable(option.label))
|
onSubmit(bridgeToLocal(option.value) ?? AnyCodable(option.label))
|
||||||
case "multiselect":
|
case "multiselect":
|
||||||
let values = optionItems
|
let values = optionItems
|
||||||
.filter { selectedIndices.contains($0.index) }
|
.filter { selectedIndices.contains($0.index) }
|
||||||
.map { $0.option.value ?? AnyCodable($0.option.label) }
|
.map { bridgeToLocal($0.option.value) ?? AnyCodable($0.option.label) }
|
||||||
onSubmit(AnyCodable(values))
|
onSubmit(AnyCodable(values))
|
||||||
case "action":
|
case "action":
|
||||||
onSubmit(AnyCodable(true))
|
onSubmit(AnyCodable(true))
|
||||||
|
|||||||
Reference in New Issue
Block a user