From 1133d7fcbaf95e615ff14acc3dcb970013d84a93 Mon Sep 17 00:00:00 2001 From: Leigh Pointer Date: Sat, 14 Dec 2024 11:09:54 +0100 Subject: [PATCH] User Profile Update: Utilizing User Settings Object This pull request updates the User Profile implementation to utilize the existing User Settings object on the user object. While the current implementation is functional, this change offers several benefits: Improved code consistency Better guidance for developers accessing User Settings Alignment with the framework's best practices --- .../Modules/Admin/UserProfile/Index.razor | 34 +++++++++---------- Oqtane.Client/Modules/Admin/Users/Edit.razor | 18 +++++----- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor index 5a63de2d..63486fc7 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/Index.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/Index.razor @@ -226,11 +226,11 @@ {
-   -   - @Localizer["From"] - @Localizer["Subject"] - @Localizer["Received"] +   +   + @Localizer["From"] + @Localizer["Subject"] + @Localizer["Received"]
@@ -289,11 +289,11 @@ {
- - - @Localizer["To"] - @Localizer["Subject"] - @Localizer["Sent"] + + + @Localizer["To"] + @Localizer["Subject"] + @Localizer["Sent"]
@@ -371,7 +371,7 @@ private File photo = null; private string _ImageFiles = string.Empty; private List profiles; - private Dictionary settings; + private Dictionary userSettings; private string category = string.Empty; private string filter = "to"; @@ -419,9 +419,9 @@ photo = null; } - settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId); + userSettings = PageState.User.Settings; var sitesettings = await SettingService.GetSiteSettingsAsync(PageState.Site.SiteId); - _ImageFiles = SettingService.GetSetting(settings, "ImageFiles", Constants.ImageFiles); + _ImageFiles = SettingService.GetSetting(userSettings, "ImageFiles", Constants.ImageFiles); _ImageFiles = (string.IsNullOrEmpty(_ImageFiles)) ? Constants.ImageFiles : _ImageFiles; await LoadNotificationsAsync(); @@ -448,7 +448,7 @@ private string GetProfileValue(string SettingName, string DefaultValue) { - string value = SettingService.GetSetting(settings, SettingName, DefaultValue); + string value = SettingService.GetSetting(userSettings, SettingName, DefaultValue); if (value.Contains("]")) { value = value.Substring(value.IndexOf("]") + 1); @@ -491,7 +491,7 @@ user = await UserService.UpdateUserAsync(user); if (user != null) { - await SettingService.UpdateUserSettingsAsync(settings, PageState.User.UserId); + await SettingService.UpdateUserSettingsAsync(userSettings, PageState.User.UserId); await logger.LogInformation("User Profile Saved"); if (!string.IsNullOrEmpty(PageState.ReturnUrl)) @@ -562,7 +562,7 @@ var value = GetProfileValue(profile.Name, string.Empty); if (string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(profile.DefaultValue)) { - settings = SettingService.SetSetting(settings, profile.Name, profile.DefaultValue); + userSettings = SettingService.SetSetting(userSettings, profile.Name, profile.DefaultValue); } if (!profile.IsPrivate || UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) { @@ -594,7 +594,7 @@ private void ProfileChanged(ChangeEventArgs e, string SettingName) { var value = (string)e.Value; - settings = SettingService.SetSetting(settings, SettingName, value); + userSettings = SettingService.SetSetting(userSettings, SettingName, value); } private async Task Delete(Notification Notification) diff --git a/Oqtane.Client/Modules/Admin/Users/Edit.razor b/Oqtane.Client/Modules/Admin/Users/Edit.razor index 0fe4af2a..a58af948 100644 --- a/Oqtane.Client/Modules/Admin/Users/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Users/Edit.razor @@ -89,8 +89,8 @@ }
-
- @if (!string.IsNullOrEmpty(p.Options)) +
+ @if (!string.IsNullOrEmpty(p.Options)) {