diff --git a/ChatController/ChatMainControl.xaml.cs b/ChatController/ChatMainControl.xaml.cs index 2b2d67b..66f2002 100644 --- a/ChatController/ChatMainControl.xaml.cs +++ b/ChatController/ChatMainControl.xaml.cs @@ -249,7 +249,7 @@ namespace ChatController notifyIcon.BalloonTipClosed += (sender, args) => { // TODO: wird beim ausblenden bzw. automatischem Schließen des "Balloons" ausgelöst - //DisposeAndRemoveNotification((NotifyIcon)sender, pGroupId); + DisposeAndRemoveNotification((NotifyIcon)sender, pGroupId); }; _Group2NotifyIcons.AddOrUpdateValueInDictionary(pGroupId, notifyIcon); @@ -276,8 +276,7 @@ namespace ChatController { pNotification.Dispose(); _Group2NotifyIcons.Remove(pGroupId); - - + Application.DoEvents(); } @@ -732,6 +731,11 @@ namespace ChatController { foreach (var newContact in contacts) { + if(newContact == null) + { + continue; + } + if (contact.GroupId == newContact.GroupId) { // ReceivedMessage kann null sein! @@ -741,9 +745,15 @@ namespace ChatController contact.TimeStamp = newContact.TimeStamp; var selectedContact = (Contact) Clientlist.SelectedItem; + // Angemeldeter Benutzer var userOid = _Chat.ChatDaten.LoggedInUser.Response.User.Oid; - if (selectedContact != null && !selectedContact.GroupId.Equals(newContact.GroupId) || selectedContact == null || _IsInBackground && userOid != contact?.ReceivedMessage?.UserId) + var senderId = contact.ReceivedMessage?.UserId; + var receiverId = userOid; + var receiverGroupId = newContact.GroupId; + var selectedGroupId = selectedContact?.GroupId; + + if(senderId != receiverId && (_IsInBackground || receiverGroupId != selectedGroupId)) { ContainingWindow.Icon = Utils.GetImageSourceFromIcon(Resource.oC_favico_NewMessage); ShowNotification(newContact.Name, newContact.ReceivedMessage, newContact.GroupId);