Skip to content

Commit d0334b7

Browse files
author
Fabian Kirchweger
committed
fix: compile errors - field initializers in collection, desktop scope
- Move _statusText/_retryButton initialization out of collection initializer - Use panel.Children index to assign field references after construction - Fix 'desktop' variable scope in DeskLinkApp.cs
1 parent 08687d5 commit d0334b7

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/HaDeskLink/DeskLinkApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private void StartWebSocket(Config config, HaApiClient api)
7878
);
7979

8080
// Pass WS to MainWindow for retry button
81-
if (desktop.MainWindow is Views.MainWindow mw)
81+
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime dt && dt.MainWindow is Views.MainWindow mw)
8282
mw.SetWebSocketClient(_ws);
8383

8484
_ = Task.Run(async () =>

src/HaDeskLink/Views/MainWindow.axaml.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public MainWindow(Config config, HaApiClient api)
138138
},
139139

140140
// Status text (for login failure messages)
141-
_statusText = new TextBlock
141+
new TextBlock
142142
{
143143
Text = "",
144144
FontSize = 13,
@@ -148,7 +148,7 @@ public MainWindow(Config config, HaApiClient api)
148148
},
149149

150150
// Retry button (hidden by default)
151-
_retryButton = new Button
151+
new Button
152152
{
153153
Content = "🔄 Erneut verbinden",
154154
FontSize = 14,
@@ -168,8 +168,10 @@ public MainWindow(Config config, HaApiClient api)
168168
var quickActionsBtn = (Button)panel.Children[4];
169169
quickActionsBtn.Click += OnQuickActions;
170170

171-
// Retry button
172-
_retryButton!.Click += OnRetryClicked;
171+
// Status text and retry button references
172+
_statusText = (TextBlock)panel.Children[7];
173+
_retryButton = (Button)panel.Children[8];
174+
_retryButton.Click += OnRetryClicked;
173175

174176
Content = panel;
175177
}

0 commit comments

Comments
 (0)