Cache optimiert.
Maximale Breite von Chatnachrichtlistitem auf 500 gesetzt.
This commit is contained in:
@@ -37,6 +37,9 @@
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DevExpress.Mvvm.v17.1, Version=17.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\libs\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -299,7 +299,7 @@
|
||||
<DataTemplate DataType="chatKlassen:ChatMessage">
|
||||
<StackPanel>
|
||||
<Border>
|
||||
<Grid HorizontalAlignment="Stretch" Background="Transparent">
|
||||
<Grid HorizontalAlignment="Stretch" Background="Transparent" MaxWidth="500">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UserMessages>(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<UserMessages>(response.Content);
|
||||
|
||||
@@ -290,6 +297,9 @@ namespace ChatController.HauptKlassen
|
||||
|
||||
client.ExecuteAsync(request, response =>
|
||||
{
|
||||
// TODO: Entfernen
|
||||
Debug.WriteLine(response.Content);
|
||||
|
||||
var messageCounter = JsonConvert.DeserializeObject<MessageCounter>(response.Content);
|
||||
|
||||
callback?.Invoke(messageCounter.MessageCount);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user