From cd26ac11c389da2bd711b967ccfddcb32cdfc8e4 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 87c9a9e..56c1460 100644 --- a/PolyChat/Controller.cs +++ b/PolyChat/Controller.cs @@ -105,8 +105,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); }