Fix filtering of notifications depending on participant assignment to shipcall in case the notification has no participant id

This commit is contained in:
Daniel Schick 2025-02-03 11:14:51 +01:00
parent 64c6607076
commit fce897fae4
2 changed files with 17 additions and 2 deletions

View File

@ -95,11 +95,11 @@ namespace BreCalClient
SaveNotifications(); SaveNotifications();
} }
internal static bool UpdateNotifications(List<BreCalClient.misc.Model.Notification> notifications, System.Collections.Concurrent.ConcurrentDictionary<int, ShipcallControlModel> currentShipcalls, ToastViewModel vm) internal static bool UpdateNotifications(List<Notification> notifications, System.Collections.Concurrent.ConcurrentDictionary<int, ShipcallControlModel> currentShipcalls, ToastViewModel vm)
{ {
bool result = false; bool result = false;
foreach (BreCalClient.misc.Model.Notification notification in notifications) foreach (Notification notification in notifications)
{ {
if (notification.ParticipantId.HasValue && notification.ParticipantId.Value != App.Participant.Id) // not meant for us if (notification.ParticipantId.HasValue && notification.ParticipantId.Value != App.Participant.Id) // not meant for us
continue; continue;
@ -107,6 +107,20 @@ namespace BreCalClient
if (!currentShipcalls.ContainsKey(notification.ShipcallId)) // not one of our shipcalls (maybe for another port or filtered) if (!currentShipcalls.ContainsKey(notification.ShipcallId)) // not one of our shipcalls (maybe for another port or filtered)
continue; continue;
// filter out notifications for shipcalls where we are not nomiated/assigned
if (!notification.ParticipantId.HasValue)
{
bool iAmAssigned = false;
foreach (ParticipantAssignment p in currentShipcalls[notification.ShipcallId].AssignedParticipants.Values)
{
if (p.ParticipantId.Equals(App.Participant.Id))
{
iAmAssigned = true; break;
}
}
if (!iAmAssigned) continue;
}
if (!_notificationsCollection.Where(x => x.Id == notification.Id).Any()) if (!_notificationsCollection.Where(x => x.Id == notification.Id).Any())
{ {
List<AppNotification> newList = new(_notificationsCollection); List<AppNotification> newList = new(_notificationsCollection);

View File

@ -35,6 +35,7 @@
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding NotificationType}" Value="MissingData"> <DataTrigger Binding="{Binding NotificationType}" Value="MissingData">
<Setter Property="Foreground" Value="Yellow" /> <Setter Property="Foreground" Value="Yellow" />
<Setter Property="Background" Value="DarkGray" />
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding NotificationType}" Value="Cancelled"> <DataTrigger Binding="{Binding NotificationType}" Value="Cancelled">
<Setter Property="Background" Value="LightGray" /> <Setter Property="Background" Value="LightGray" />