Fix: ConnectView zeigte nie Verbindungsstatus an

connectionService war nur über viewModel.connectionService erreichbar,
ein zwei Ebenen tief verschachteltes ObservableObject. SwiftUI abonniert
automatisch nur Objekte, die eine View direkt per @StateObject/
@ObservedObject hält — nicht transitiv erreichte. Dadurch blieb die
Oberfläche beim echten Verbindungstest (physisches Mikrotik-Gerät)
komplett unverändert hängen, obwohl die Verbindung im Hintergrund
korrekt lief oder fehlschlug.

Fix: ConnectView hält connectionService jetzt zusätzlich selbst als
@ObservedObject, direkt von der App-Ebene durchgereicht.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HReLXMbmPvtQ23p1iWiJNW
This commit is contained in:
Kay
2026-09-11 21:29:56 +02:00
co-authored by Claude Sonnet 5
parent 87f4fa188c
commit 6c230827be
@@ -1,9 +1,11 @@
import SwiftUI
struct ConnectView: View {
@ObservedObject private var connectionService: ConnectionService
@StateObject private var viewModel: ConnectViewModel
init(connectionService: ConnectionService) {
self.connectionService = connectionService
_viewModel = StateObject(wrappedValue: ConnectViewModel(connectionService: connectionService))
}
@@ -47,7 +49,7 @@ struct ConnectView: View {
}
private var certificateFingerprint: String? {
if case .needsCertificateConfirmation(let fingerprint) = viewModel.connectionService.state {
if case .needsCertificateConfirmation(let fingerprint) = connectionService.state {
return fingerprint
}
return nil
@@ -62,7 +64,7 @@ struct ConnectView: View {
@ViewBuilder
private var statusSection: some View {
switch viewModel.connectionService.state {
switch connectionService.state {
case .idle, .needsCertificateConfirmation:
EmptyView()
case .connecting:
@@ -87,7 +89,7 @@ struct ConnectView: View {
@ViewBuilder
private var deviceDetail: some View {
if let info = viewModel.connectionService.deviceInfo {
if let info = connectionService.deviceInfo {
List {
Section("Gerät") {
LabeledContent("Modell", value: info.boardName)
@@ -96,7 +98,7 @@ struct ConnectView: View {
LabeledContent("Laufzeit", value: info.uptime)
}
Section("Interfaces") {
ForEach(viewModel.connectionService.interfaces) { interface in
ForEach(connectionService.interfaces) { interface in
HStack {
Image(systemName: interface.running ? "circle.fill" : "circle")
.foregroundStyle(interface.running ? .green : .secondary)