diff --git a/ChatController/ChatController.csproj b/ChatController/ChatController.csproj index adde9fb..2e5e772 100644 --- a/ChatController/ChatController.csproj +++ b/ChatController/ChatController.csproj @@ -37,6 +37,9 @@ + + False + ..\libs\Newtonsoft.Json.dll diff --git a/ChatController/ChatKlassen/ChatMessage.cs b/ChatController/ChatKlassen/ChatMessage.cs index bbeb2db..a2c9432 100644 --- a/ChatController/ChatKlassen/ChatMessage.cs +++ b/ChatController/ChatKlassen/ChatMessage.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.Diagnostics; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Media; @@ -275,6 +276,8 @@ namespace ChatController.ChatKlassen { if(IsHyperlink(UserMessage)) { + Debug.WriteLine($"Link: {UserMessage}"); + if(!UserMessage.Contains("http")) { return new Uri("http://" + UserMessage); diff --git a/ChatController/ChatMainControl.xaml b/ChatController/ChatMainControl.xaml index 0774e61..3c687ba 100644 --- a/ChatController/ChatMainControl.xaml +++ b/ChatController/ChatMainControl.xaml @@ -299,7 +299,7 @@ - + diff --git a/ChatController/Core/OwnChatCache.cs b/ChatController/Core/OwnChatCache.cs index 92e6335..cec0077 100644 --- a/ChatController/Core/OwnChatCache.cs +++ b/ChatController/Core/OwnChatCache.cs @@ -66,7 +66,7 @@ namespace ChatController.Core } } - public void AddProfilePictureToCache(string key, ImageSource imageSource) + public void AddProfilePictureToCache(string key, ImageSource imageSource, string profilePicturePath) { lock(_Lock) { @@ -75,17 +75,25 @@ namespace ChatController.Core _ImageSourceCache.Add(key, new ImageSourceCacheStorage()); } - _ImageSourceCache[key].SetCachedProfilePicture(imageSource); + _ImageSourceCache[key].SetCachedProfilePicture(imageSource, profilePicturePath); } } - public ImageSource GetCachedProfilePicture(string key) + public ImageSource GetCachedProfilePicture(string key, string uri) { lock(_Lock) { + foreach (var kvp in _ImageSourceCache) + { + if(!string.IsNullOrWhiteSpace(uri) && uri.ToLower().Contains("ownchat") && kvp.Value.ProfilePicturePath == uri) + { + return kvp.Value.GetCachedProfilePicture(); + } + } + return _ImageSourceCache.ContainsKey(key) ? - _ImageSourceCache[key].GetCachedProfilePicture() : - null; + _ImageSourceCache[key].GetCachedProfilePicture() : + null; } } } @@ -94,15 +102,18 @@ namespace ChatController.Core { private ImageSourceCacheObject _ProfilePicture; + public string ProfilePicturePath { get; set; } + public ImageSource GetCachedProfilePicture() { return _ProfilePicture?.ExpirationDate > DateTime.Now ? _ProfilePicture.Image : null; } - public void SetCachedProfilePicture(ImageSource avatarImageSource) + public void SetCachedProfilePicture(ImageSource avatarImageSource, string profilePicturePath) { - if(avatarImageSource != null) + if(avatarImageSource != null && !string.IsNullOrWhiteSpace(profilePicturePath)) { + ProfilePicturePath = profilePicturePath; _ProfilePicture = new ImageSourceCacheObject(avatarImageSource, CacheCategory.ProfilePicture); } } diff --git a/ChatController/HauptKlassen/Chat.cs b/ChatController/HauptKlassen/Chat.cs index 2f873cd..888e8e7 100644 --- a/ChatController/HauptKlassen/Chat.cs +++ b/ChatController/HauptKlassen/Chat.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -145,6 +146,9 @@ namespace ChatController.HauptKlassen client.ExecuteAsync(request, response => { + // TODO: Entfernen + Debug.WriteLine(response.Content); + _UserMessages = JsonConvert.DeserializeObject(response.Content); if (_UserMessages.Response.HasMorePages) @@ -196,6 +200,9 @@ namespace ChatController.HauptKlassen client.ExecuteAsync(request, response => { + // TODO: Entfernen + Debug.WriteLine(response.Content); + _AdditionalUserMessages = null; _AdditionalUserMessages = JsonConvert.DeserializeObject(response.Content); @@ -290,6 +297,9 @@ namespace ChatController.HauptKlassen client.ExecuteAsync(request, response => { + // TODO: Entfernen + Debug.WriteLine(response.Content); + var messageCounter = JsonConvert.DeserializeObject(response.Content); callback?.Invoke(messageCounter.MessageCount); diff --git a/ChatController/Utilities/Utils.cs b/ChatController/Utilities/Utils.cs index de8909f..4519508 100644 --- a/ChatController/Utilities/Utils.cs +++ b/ChatController/Utilities/Utils.cs @@ -30,7 +30,7 @@ namespace ChatController.Utilities { var cache = OwnChatCache.GetInstance(); - var cachedProfileImage = cache.GetCachedProfilePicture(key); + var cachedProfileImage = cache.GetCachedProfilePicture(key, pathToProfilePicture); if(cachedProfileImage != null) { @@ -58,7 +58,7 @@ namespace ChatController.Utilities bitmap.EndInit(); bitmap.Freeze(); - cache.AddProfilePictureToCache(key, bitmap); + cache.AddProfilePictureToCache(key, bitmap, pathToProfilePicture); callback?.Invoke(bitmap); } diff --git a/PrototypChat/.vs/PrototypChat/v16/.suo b/PrototypChat/.vs/PrototypChat/v16/.suo index f1e1a22..06aa56a 100644 Binary files a/PrototypChat/.vs/PrototypChat/v16/.suo and b/PrototypChat/.vs/PrototypChat/v16/.suo differ