diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index 7ff54a15..f77c3970 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -355,7 +355,7 @@ // appearance _title = _page.Title; _themetype = _page.ThemeType; - if (string.IsNullOrEmpty(_themetype)) + if (string.IsNullOrEmpty(_themetype) || ThemeService.GetTheme(PageState.Site.Themes, _themetype)?.ThemeName != ThemeService.GetTheme(PageState.Site.Themes, PageState.Site.DefaultThemeType)?.ThemeName) { _themetype = PageState.Site.DefaultThemeType; } diff --git a/Oqtane.Client/Services/Interfaces/IThemeService.cs b/Oqtane.Client/Services/Interfaces/IThemeService.cs index aafff7b2..6ad83fba 100644 --- a/Oqtane.Client/Services/Interfaces/IThemeService.cs +++ b/Oqtane.Client/Services/Interfaces/IThemeService.cs @@ -24,6 +24,13 @@ namespace Oqtane.Services /// Task GetThemeAsync(int themeId, int siteId); + /// + /// Returns a theme s containing a theme control type + /// + /// + /// + Theme GetTheme(List themes, string themeType); + /// /// Returns a list of s from the given themes /// diff --git a/Oqtane.Client/Services/ThemeService.cs b/Oqtane.Client/Services/ThemeService.cs index b86b63e1..e4cf06d6 100644 --- a/Oqtane.Client/Services/ThemeService.cs +++ b/Oqtane.Client/Services/ThemeService.cs @@ -26,6 +26,11 @@ namespace Oqtane.Services return await GetJsonAsync($"{ApiUrl}/{themeId}?siteid={siteId}"); } + public Theme GetTheme(List themes, string themeType) + { + return themes.FirstOrDefault(item => item.Themes.Any(item => item.TypeName == themeType)); + } + public List GetThemeControls(List themes) { return themes.SelectMany(item => item.Themes).OrderBy(item => item.Name).ToList(); @@ -33,13 +38,13 @@ namespace Oqtane.Services public List GetThemeControls(List themes, string themeType) { - return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Themes.OrderBy(item => item.Name).ToList(); + return GetTheme(themes, themeType)?.Themes.OrderBy(item => item.Name).ToList(); } public List GetContainerControls(List themes, string themeType) { - return themes.First(item => item.Themes.Any(item => item.TypeName == themeType)).Containers.OrderBy(item => item.Name).ToList(); + return GetTheme(themes, themeType)?.Containers.OrderBy(item => item.Name).ToList(); } public async Task UpdateThemeAsync(Theme theme)