From 49ab1c4bd2d61a9ffb1f588ea459ab52eff7fd70 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Sat, 21 Nov 2020 09:47:36 -0500 Subject: [PATCH] fix double identity shown on 'add identity' --- DesktopEdge/MainWindow.xaml.cs | 15 +++++++++++---- service/quick.bat | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 2ac4c4fb..e4a75f1c 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -49,6 +49,14 @@ namespace ZitiDesktopEdge { } } + private void AddIdentity(ZitiIdentity id) { + semaphoreSlim.Wait(); + if (!identities.Any(i => id.Fingerprint == i.Fingerprint)) { + identities.Add(id); + } + semaphoreSlim.Release(); + } + public MainWindow() { InitializeComponent(); @@ -323,7 +331,6 @@ namespace ZitiDesktopEdge { async private void LogLevelChanged(string level) { await serviceClient.SetLogLevelAsync(level); - Logger.Info("shouldhave read here"); } private void IdentityMenu_OnError(string message) { @@ -362,7 +369,7 @@ namespace ZitiDesktopEdge { if (e.Action == "added") { var found = identities.Find(i => i.Fingerprint == e.Id.FingerPrint); if (found == null) { - identities.Add(zid); + AddIdentity(zid); LoadIdentities(true); } else { //if we get here exit out so that LoadIdentities() doesn't get called @@ -428,7 +435,6 @@ namespace ZitiDesktopEdge { Debug.WriteLine("removing the service named: " + e.Service.Name); found.Services.RemoveAll(s => s.Name == e.Service.Name); } - LoadIdentities(false); IdentityDetails deets = ((MainWindow)Application.Current.MainWindow).IdentityMenu; if (deets.IsVisible) { deets.UpdateView(); @@ -675,7 +681,8 @@ namespace ZitiDesktopEdge { await serviceClient.IdentityOnOffAsync(createdId.FingerPrint, true); if (createdId != null) { - identities.Add(ZitiIdentity.FromClient(createdId)); + var zid = ZitiIdentity.FromClient(createdId); + AddIdentity(zid); LoadIdentities(true); } else { ShowError("Identity Error", "Identity Id was null, please try again"); diff --git a/service/quick.bat b/service/quick.bat index 002b4b0a..23264ad8 100644 --- a/service/quick.bat +++ b/service/quick.bat @@ -1,4 +1,4 @@ -@echo off +echo off REM Copyright NetFoundry, Inc. REM REM Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,4 +13,5 @@ REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. REM +SET ZITI_DEBUG=true call build quick