From 1b3d1336571bd9f88d130216df10e065cc96aa1f Mon Sep 17 00:00:00 2001 From: "Felix Hartmann (PEA3-Fe-FI)" Date: Thu, 23 Sep 2021 09:41:56 +0200 Subject: [PATCH] allow deletion of chats which are not started by me --- PolyChat/Controller.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PolyChat/Controller.cs b/PolyChat/Controller.cs index 08762db..0dc6368 100644 --- a/PolyChat/Controller.cs +++ b/PolyChat/Controller.cs @@ -102,8 +102,12 @@ namespace PolyChat public void CloseChat(string IP, bool wasConnected = true) { - Connections[IP].Close(); - Connections.Remove(IP); + Debug.WriteLine($"Deleting connection with IP:{IP}"); + if (IP != null && Connections.ContainsKey(IP)) + { + Connections[IP].Close(); + Connections.Remove(IP); + } CloseChatUI(IP,wasConnected); }