From e2fd6961e25ff88508dd7608d12b064ab1d14bc3 Mon Sep 17 00:00:00 2001 From: Adam Shiervani Date: Thu, 23 Oct 2025 15:26:48 +0000 Subject: [PATCH] refactor: rename to RedirectTo --- network.go | 6 +++--- ota.go | 6 +++--- ui/src/components/VideoOverlay.tsx | 4 ++-- ui/src/hooks/stores.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/network.go b/network.go index 83eae429..846f41f1 100644 --- a/network.go +++ b/network.go @@ -29,7 +29,7 @@ func (s *RpcNetworkSettings) ToNetworkConfig() *types.NetworkConfig { type PostRebootAction struct { HealthCheck string `json:"healthCheck"` - RedirectUrl string `json:"redirectUrl"` + RedirectTo string `json:"redirectTo"` } func toRpcNetworkSettings(config *types.NetworkConfig) *RpcNetworkSettings { @@ -202,7 +202,7 @@ func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (re if newIPv4Mode == "static" && oldIPv4Mode != "static" { postRebootAction = &PostRebootAction{ HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String), - RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String), + RedirectTo: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String), } l.Info().Interface("postRebootAction", postRebootAction).Msg("IPv4 mode changed to static, reboot required") } @@ -219,7 +219,7 @@ func shouldRebootForNetworkChange(oldConfig, newConfig *types.NetworkConfig) (re newConfig.IPv4Static.Address.String != oldConfig.IPv4Static.Address.String { postRebootAction = &PostRebootAction{ HealthCheck: fmt.Sprintf("//%s/device/status", newConfig.IPv4Static.Address.String), - RedirectUrl: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String), + RedirectTo: fmt.Sprintf("//%s", newConfig.IPv4Static.Address.String), } l.Info().Interface("postRebootAction", postRebootAction).Msg("IPv4 static config changed, reboot required") diff --git a/ota.go b/ota.go index d90627bb..65a67517 100644 --- a/ota.go +++ b/ota.go @@ -490,7 +490,7 @@ func TryUpdate(ctx context.Context, deviceId string, includePreRelease bool) err scopedLogger.Info().Msg("System Rebooting due to OTA update") // Build redirect URL with conditional query parameters - redirectUrl := "/settings/general/update" + redirectTo := "/settings/general/update" queryParams := url.Values{} if systemUpdateAvailable { queryParams.Set("systemVersion", remote.SystemVersion) @@ -499,12 +499,12 @@ func TryUpdate(ctx context.Context, deviceId string, includePreRelease bool) err queryParams.Set("appVersion", remote.AppVersion) } if len(queryParams) > 0 { - redirectUrl += "?" + queryParams.Encode() + redirectTo += "?" + queryParams.Encode() } postRebootAction := &PostRebootAction{ HealthCheck: "/device/status", - RedirectUrl: redirectUrl, + RedirectTo: redirectTo, } if err := hwReboot(true, postRebootAction, 10*time.Second); err != nil { diff --git a/ui/src/components/VideoOverlay.tsx b/ui/src/components/VideoOverlay.tsx index 7697399b..1b565d81 100644 --- a/ui/src/components/VideoOverlay.tsx +++ b/ui/src/components/VideoOverlay.tsx @@ -474,13 +474,13 @@ export function RebootingOverlay({ show, postRebootAction }: RebootingOverlayPro if (response.ok) { // Device is available, redirect to the specified URL - console.log('Device is available, redirecting to:', postRebootAction.redirectUrl); + console.log('Device is available, redirecting to:', postRebootAction.redirectTo); // URL constructor handles all cases elegantly: // - Absolute paths: resolved against current origin // - Protocol-relative URLs: resolved with current protocol // - Fully qualified URLs: used as-is - const targetUrl = new URL(postRebootAction.redirectUrl, window.location.origin); + const targetUrl = new URL(postRebootAction.redirectTo, window.location.origin); window.location.href = targetUrl.href; } diff --git a/ui/src/hooks/stores.ts b/ui/src/hooks/stores.ts index 052c8d9a..7157354f 100644 --- a/ui/src/hooks/stores.ts +++ b/ui/src/hooks/stores.ts @@ -21,7 +21,7 @@ interface JsonRpcResponse { export type PostRebootAction = { healthCheck: string; - redirectUrl: string; + redirectTo: string; } | null; // Utility function to append stats to a Map