Avatare von Mitgliedern in Gruppenchats mit Default-Avatar werden jetzt angezeigt
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using ChatController.Extensions;
|
using ChatController.Extensions;
|
||||||
@@ -52,6 +51,9 @@ namespace ChatController.Core
|
|||||||
|
|
||||||
private List<ProfilePictureObject> _AvatarCache = new List<ProfilePictureObject>();
|
private List<ProfilePictureObject> _AvatarCache = new List<ProfilePictureObject>();
|
||||||
|
|
||||||
|
private List<long> EmployeesWithDefaultAvatar = new List<long>();
|
||||||
|
private List<long> ClientsWithDefaultAvatar = new List<long>();
|
||||||
|
|
||||||
public void AddAvatar(string uri, ImageSource avatar, long? userId, int? groupId)
|
public void AddAvatar(string uri, ImageSource avatar, long? userId, int? groupId)
|
||||||
{
|
{
|
||||||
lock(_Lock)
|
lock(_Lock)
|
||||||
@@ -76,6 +78,10 @@ namespace ChatController.Core
|
|||||||
if(uri.Equals($"{BaseUri}/ownChat_avatar_employee.png"))
|
if(uri.Equals($"{BaseUri}/ownChat_avatar_employee.png"))
|
||||||
{
|
{
|
||||||
_DefaultAvatars.AddAndIgnoreDuplicates(DefaultAvatarType.Employee, avatar);
|
_DefaultAvatars.AddAndIgnoreDuplicates(DefaultAvatarType.Employee, avatar);
|
||||||
|
if(userId.HasValue)
|
||||||
|
{
|
||||||
|
EmployeesWithDefaultAvatar.AddIfNotIn(userId.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uri.Equals($"{BaseUri}/ownChat_avatar_employee_group.png"))
|
if(uri.Equals($"{BaseUri}/ownChat_avatar_employee_group.png"))
|
||||||
@@ -86,6 +92,10 @@ namespace ChatController.Core
|
|||||||
if(uri.Equals($"{BaseUri}/ownChat_avatar_client.png"))
|
if(uri.Equals($"{BaseUri}/ownChat_avatar_client.png"))
|
||||||
{
|
{
|
||||||
_DefaultAvatars.AddAndIgnoreDuplicates(DefaultAvatarType.Client, avatar);
|
_DefaultAvatars.AddAndIgnoreDuplicates(DefaultAvatarType.Client, avatar);
|
||||||
|
if(userId.HasValue)
|
||||||
|
{
|
||||||
|
ClientsWithDefaultAvatar.AddIfNotIn(userId.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uri.Equals($"{BaseUri}/ownChat_avatar_client_group.png"))
|
if(uri.Equals($"{BaseUri}/ownChat_avatar_client_group.png"))
|
||||||
@@ -119,6 +129,11 @@ namespace ChatController.Core
|
|||||||
|
|
||||||
if(uri.Equals($"{BaseUri}/ownChat_avatar_employee.png"))
|
if(uri.Equals($"{BaseUri}/ownChat_avatar_employee.png"))
|
||||||
{
|
{
|
||||||
|
if(userId.HasValue)
|
||||||
|
{
|
||||||
|
EmployeesWithDefaultAvatar.AddIfNotIn(userId.Value);
|
||||||
|
}
|
||||||
|
|
||||||
return _DefaultAvatars[DefaultAvatarType.Employee];
|
return _DefaultAvatars[DefaultAvatarType.Employee];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +144,11 @@ namespace ChatController.Core
|
|||||||
|
|
||||||
if(uri.Equals($"{BaseUri}/ownChat_avatar_client.png"))
|
if(uri.Equals($"{BaseUri}/ownChat_avatar_client.png"))
|
||||||
{
|
{
|
||||||
|
if(userId.HasValue)
|
||||||
|
{
|
||||||
|
ClientsWithDefaultAvatar.AddIfNotIn(userId.Value);
|
||||||
|
}
|
||||||
|
|
||||||
return _DefaultAvatars[DefaultAvatarType.Client];
|
return _DefaultAvatars[DefaultAvatarType.Client];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +171,24 @@ namespace ChatController.Core
|
|||||||
{
|
{
|
||||||
lock(_Lock)
|
lock(_Lock)
|
||||||
{
|
{
|
||||||
return _AvatarCache.FirstOrDefault(f => f.UserId.HasValue && f.UserId.Value.Equals(userId))?.ProfilePicture;
|
var profilePicture = _AvatarCache.FirstOrDefault(f => f.UserId.HasValue && f.UserId.Value.Equals(userId))?.ProfilePicture;
|
||||||
|
|
||||||
|
if(!(profilePicture is null))
|
||||||
|
{
|
||||||
|
return profilePicture;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(EmployeesWithDefaultAvatar.Contains(userId))
|
||||||
|
{
|
||||||
|
profilePicture = _DefaultAvatars[DefaultAvatarType.Employee];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ClientsWithDefaultAvatar.Contains(userId))
|
||||||
|
{
|
||||||
|
profilePicture = _DefaultAvatars[DefaultAvatarType.Client];
|
||||||
|
}
|
||||||
|
|
||||||
|
return profilePicture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user