fix double identity shown on 'add identity'

This commit is contained in:
dovholuknf
2020-11-21 09:47:36 -05:00
parent 27121ccfaf
commit 49ab1c4bd2
2 changed files with 13 additions and 5 deletions
+11 -4
View File
@@ -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");
+2 -1
View File
@@ -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