From 91053e21a261b6be02961dd921db95e80cf762ff Mon Sep 17 00:00:00 2001 From: Jared Date: Thu, 4 Feb 2021 05:33:28 -0800 Subject: [PATCH] Fix GUI host prompt. --- Desktop.Core/Services/CasterSocket.cs | 10 +++++++--- Desktop.Linux/ViewModels/MainWindowViewModel.cs | 4 ++-- Desktop.Win/ViewModels/MainWindowViewModel.cs | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Desktop.Core/Services/CasterSocket.cs b/Desktop.Core/Services/CasterSocket.cs index d85dd98d..dc69873c 100644 --- a/Desktop.Core/Services/CasterSocket.cs +++ b/Desktop.Core/Services/CasterSocket.cs @@ -59,10 +59,14 @@ namespace Remotely.Desktop.Core.Services { try { - if (Connection != null) + if (Connection?.State == HubConnectionState.Connected) { - await Connection.StopAsync(); - await Connection.DisposeAsync(); + try + { + await Connection.StopAsync(); + await Connection.DisposeAsync(); + } + catch { } } Connection = new HubConnectionBuilder() .WithUrl($"{host}/CasterHub") diff --git a/Desktop.Linux/ViewModels/MainWindowViewModel.cs b/Desktop.Linux/ViewModels/MainWindowViewModel.cs index f94f3686..60b577fe 100644 --- a/Desktop.Linux/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Linux/ViewModels/MainWindowViewModel.cs @@ -206,7 +206,7 @@ namespace Remotely.Desktop.Linux.ViewModels } prompt.Owner = MainWindow.Current; await prompt.ShowDialog(MainWindow.Current); - var result = prompt.ViewModel.Host; + var result = prompt.ViewModel.Host?.TrimEnd('/'); if (result is null) { @@ -219,7 +219,7 @@ namespace Remotely.Desktop.Linux.ViewModels } if (result != Host) { - Host = result.TrimEnd('/'); + Host = result; var config = ConfigService.GetConfig(); config.Host = Host; ConfigService.Save(config); diff --git a/Desktop.Win/ViewModels/MainWindowViewModel.cs b/Desktop.Win/ViewModels/MainWindowViewModel.cs index a89fcea5..315a7b4a 100644 --- a/Desktop.Win/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Win/ViewModels/MainWindowViewModel.cs @@ -251,14 +251,14 @@ namespace Remotely.Desktop.Win.ViewModels } prompt.Owner = App.Current?.MainWindow; prompt.ShowDialog(); - var result = prompt.ViewModel.Host; + var result = prompt.ViewModel.Host?.TrimEnd('/'); if (!result.StartsWith("https://") && !result.StartsWith("http://")) { result = $"https://{result}"; } if (result != Host) { - Host = result.TrimEnd('/'); + Host = result; var config = ConfigService.GetConfig(); config.Host = Host; ConfigService.Save(config);