mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented user image cache update on settings update
This commit is contained in:
@@ -56,7 +56,13 @@ public class SettingsController : Controller
|
||||
ErrorMessage = "adminUpdateRequestModel is null"
|
||||
};
|
||||
}
|
||||
AdminSettingsModel currentSettingsModel = await _ldap.GetAdminSettingsModelAsync();
|
||||
await _ldap.SetAdminSettingsModelAsync(adminSettingsRequestModel.AdminSettingsModel);
|
||||
if (adminSettingsRequestModel.AdminSettingsModel.UserImagePreloadType != currentSettingsModel.UserImagePreloadType)
|
||||
{
|
||||
IEnumerable<UserModel> users = await _ldap.ListUsersAsync();
|
||||
Task _ = ImageHelper.PreloadUsers(users, adminSettingsRequestModel.AdminSettingsModel.UserImagePreloadType);
|
||||
}
|
||||
return new() {
|
||||
Success = true
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ public static class ImageHelper
|
||||
public static Dictionary<int, Dictionary<string, byte[]>> ImageCache = [];
|
||||
public static byte[] ResizeAndConvertToWebp(string imageString, int size = 32)
|
||||
{
|
||||
if (imageString.Length == 0) return [];
|
||||
if (ImageCache.TryGetValue(size, out Dictionary<string, byte[]>? sizeCache)
|
||||
&& sizeCache.TryGetValue(imageString, out byte[]? result) && result.Length > 0)
|
||||
{
|
||||
@@ -49,6 +50,7 @@ public static class ImageHelper
|
||||
{
|
||||
ResizeAndConvertToWebp(user.JpegPhoto, 256);
|
||||
}
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user