Skip to content

Commit

Permalink
fix: Fix invalid message in HR indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Jun 17, 2024
1 parent 97d0a1d commit 7a1f6eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/Uno.UI.RemoteControl/HotReload/HotReloadStatusView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ private void SyncOperations(Status status)
vm.Description = localOp.Result switch
{
null => $"Processing changes{Join(types, "types")} (total of {localOp.Types.Length} types updated).",
HotReloadClientResult.Success => $"Application received {localOp.Types.Length} changes{Join(types, "types")} and updated the view (total of {localOp.Types.Length} types updated).",
HotReloadClientResult.Failed => $"Application received {localOp.Types.Length} changes{Join(types, "types")} (total of {localOp.Types.Length} types updated) but failed to update the view ({localOp.Exceptions.FirstOrDefault()?.Message}).",
HotReloadClientResult.Ignored => $"Application received {localOp.Types.Length} changes{Join(types, "types")} (total of {localOp.Types.Length} types updated) but view was not been updated because {localOp.IgnoreReason}.",
HotReloadClientResult.Success => $"Application received changes{Join(types, "types")} and updated the view (total of {localOp.Types.Length} types updated).",
HotReloadClientResult.Failed => $"Application received changes{Join(types, "types")} (total of {localOp.Types.Length} types updated) but failed to update the view ({localOp.Exceptions.FirstOrDefault()?.Message}).",
HotReloadClientResult.Ignored => $"Application received changes{Join(types, "types")} (total of {localOp.Types.Length} types updated) but view was not been updated because {localOp.IgnoreReason}.",
_ => $"Unknown application operation result: {localOp.Result}."
};
vm.Duration = localOp.EndTime is not null ? localOp.EndTime - localOp.StartTime : null;
Expand Down
65 changes: 32 additions & 33 deletions src/Uno.UI.RemoteControl/RemoteControlStatusView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
using System.Text;
using Windows.UI;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Shapes;
using Uno.UI.RemoteControl.HotReload.Messages;
using static Uno.UI.RemoteControl.RemoteControlClient;

namespace Uno.UI.RemoteControl;

Expand All @@ -20,50 +19,50 @@ public RemoteControlStatusView()
Height = 16;
}

public void Update(RemoteControlClient.Status status)
public void Update(Status status)
{
((SolidColorBrush)Fill).Color = GetStatusColor(status);
ToolTipService.SetToolTip(this, GetStatusSummary(status));
}

private Color GetStatusColor(RemoteControlClient.Status status)
private static Color GetStatusColor(Status status)
=> status.State switch
{
RemoteControlClient.ConnectionState.Idle => Colors.Gray,
RemoteControlClient.ConnectionState.NoServer => Colors.Red,
RemoteControlClient.ConnectionState.Connecting => Colors.Yellow,
RemoteControlClient.ConnectionState.ConnectionTimeout => Colors.Red,
RemoteControlClient.ConnectionState.ConnectionFailed => Colors.Red,
RemoteControlClient.ConnectionState.Reconnecting => Colors.Yellow,
RemoteControlClient.ConnectionState.Disconnected => Colors.Red,

RemoteControlClient.ConnectionState.Connected when status.IsVersionValid is false => Colors.Orange,
RemoteControlClient.ConnectionState.Connected when status.InvalidFrames.Count is not 0 => Colors.Orange,
RemoteControlClient.ConnectionState.Connected when status.KeepAlive.State is not RemoteControlClient.KeepAliveState.Ok => Colors.Yellow,
RemoteControlClient.ConnectionState.Connected => Colors.Green,
ConnectionState.Idle => Colors.Gray,
ConnectionState.NoServer => Colors.Red,
ConnectionState.Connecting => Colors.Yellow,
ConnectionState.ConnectionTimeout => Colors.Red,
ConnectionState.ConnectionFailed => Colors.Red,
ConnectionState.Reconnecting => Colors.Yellow,
ConnectionState.Disconnected => Colors.Red,

ConnectionState.Connected when status.IsVersionValid is false => Colors.Orange,
ConnectionState.Connected when status.InvalidFrames.Count is not 0 => Colors.Orange,
ConnectionState.Connected when status.KeepAlive.State is not KeepAliveState.Ok => Colors.Yellow,
ConnectionState.Connected => Colors.Green,

_ => Colors.Gray
};

private static string GetStatusSummary(RemoteControlClient.Status status)
private static string GetStatusSummary(Status status)
{
var summary = status.State switch
{
RemoteControlClient.ConnectionState.Idle => "Initializing...",
RemoteControlClient.ConnectionState.NoServer => "No server configured, cannot initialize connection.",
RemoteControlClient.ConnectionState.Connecting => "Connecting to dev-server.",
RemoteControlClient.ConnectionState.ConnectionTimeout => "Failed to connect to dev-server (timeout).",
RemoteControlClient.ConnectionState.ConnectionFailed => "Failed to connect to dev-server (error).",
RemoteControlClient.ConnectionState.Reconnecting => "Connection to dev-server has been lost, reconnecting.",
RemoteControlClient.ConnectionState.Disconnected => "Connection to dev-server has been lost, will retry later.",

RemoteControlClient.ConnectionState.Connected when status.IsVersionValid is false => "Connected to dev-server, but version mis-match with client.",
RemoteControlClient.ConnectionState.Connected when status.InvalidFrames.Count is not 0 => $"Connected to dev-server, but received {status.InvalidFrames.Count} invalid frames from the server.",
RemoteControlClient.ConnectionState.Connected when status.MissingRequiredProcessors is { IsEmpty: false } => "Connected to dev-server, but some required processors are missing on server.",
RemoteControlClient.ConnectionState.Connected when status.KeepAlive.State is RemoteControlClient.KeepAliveState.Late => "Connected to dev-server, but keep-alive messages are taking longer than expected.",
RemoteControlClient.ConnectionState.Connected when status.KeepAlive.State is RemoteControlClient.KeepAliveState.Lost => "Connected to dev-server, but last keep-alive messages have been lost.",
RemoteControlClient.ConnectionState.Connected when status.KeepAlive.State is RemoteControlClient.KeepAliveState.Aborted => "Connected to dev-server, but keep-alive has been aborted.",
RemoteControlClient.ConnectionState.Connected => "Connected to dev-server.",
ConnectionState.Idle => "Initializing...",
ConnectionState.NoServer => "No server configured, cannot initialize connection.",
ConnectionState.Connecting => "Connecting to dev-server.",
ConnectionState.ConnectionTimeout => "Failed to connect to dev-server (timeout).",
ConnectionState.ConnectionFailed => "Failed to connect to dev-server (error).",
ConnectionState.Reconnecting => "Connection to dev-server has been lost, reconnecting.",
ConnectionState.Disconnected => "Connection to dev-server has been lost, will retry later.",

ConnectionState.Connected when status.IsVersionValid is false => "Connected to dev-server, but version mis-match with client.",
ConnectionState.Connected when status.InvalidFrames.Count is not 0 => $"Connected to dev-server, but received {status.InvalidFrames.Count} invalid frames from the server.",
ConnectionState.Connected when status.MissingRequiredProcessors is { IsEmpty: false } => "Connected to dev-server, but some required processors are missing on server.",
ConnectionState.Connected when status.KeepAlive.State is KeepAliveState.Late => "Connected to dev-server, but keep-alive messages are taking longer than expected.",
ConnectionState.Connected when status.KeepAlive.State is KeepAliveState.Lost => "Connected to dev-server, but last keep-alive messages have been lost.",
ConnectionState.Connected when status.KeepAlive.State is KeepAliveState.Aborted => "Connected to dev-server, but keep-alive has been aborted.",
ConnectionState.Connected => "Connected to dev-server.",

_ => status.State.ToString()
};
Expand All @@ -76,7 +75,7 @@ private static string GetStatusSummary(RemoteControlClient.Status status)
return summary;
}

internal static string GetStatusDetails(RemoteControlClient.Status status)
internal static string GetStatusDetails(Status status)
{
var details = new StringBuilder(GetStatusSummary(status));

Expand Down

0 comments on commit 7a1f6eb

Please sign in to comment.