Skip to content

Commit ea677bd

Browse files
Reset to base theme when no default theme is set and leaving UUID/handle theme
1 parent 887eacb commit ea677bd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/app/shared/theme-support/theme.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const themeStateSelector = createFeatureSelector<ThemeState>('theme');
2929

3030
export const currentThemeSelector = createSelector(
3131
themeStateSelector,
32-
(state: ThemeState): string => hasValue(state) ? state.currentTheme : undefined
32+
(state: ThemeState): string => hasValue(state) ? state.currentTheme : BASE_THEME_NAME,
3333
);
3434

3535
@Injectable({
@@ -262,7 +262,7 @@ export class ThemeService {
262262
}
263263

264264
// inherit the head tags of the default theme
265-
return this.createHeadTags(defaultThemeConfig.name);
265+
return this.createHeadTags(defaultThemeName);
266266
}
267267

268268
return headTagConfigs.map(this.createHeadTag.bind(this));
@@ -425,9 +425,10 @@ export class ThemeService {
425425
* @private
426426
*/
427427
private getActionForMatch(newTheme: Theme, currentThemeName: string): SetThemeAction | NoOpAction {
428-
if (hasValue(newTheme) && newTheme.config.name !== currentThemeName) {
428+
const newThemeName: string = newTheme?.config.name ?? BASE_THEME_NAME;
429+
if (newThemeName !== currentThemeName) {
429430
// If we have a match, and it isn't already the active theme, set it as the new theme
430-
return new SetThemeAction(newTheme.config.name);
431+
return new SetThemeAction(newThemeName);
431432
} else {
432433
// Otherwise, do nothing
433434
return new NoOpAction();

src/config/config.util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { environment } from '../environments/environment';
55
import { hasNoValue } from '../app/shared/empty.util';
66

77
import { AppConfig } from './app-config.interface';
8-
import { ThemeConfig } from './theme.model';
8+
import { ThemeConfig, NamedThemeConfig } from './theme.model';
9+
import { BASE_THEME_NAME } from '../app/shared/theme-support/theme.constants';
910

1011
/**
1112
* Extend Angular environment with app config.
@@ -44,7 +45,9 @@ const getDefaultThemeConfig = (): ThemeConfig => {
4445
hasNoValue(themeConfig.regex) &&
4546
hasNoValue(themeConfig.handle) &&
4647
hasNoValue(themeConfig.uuid)
47-
);
48+
) ?? {
49+
name: BASE_THEME_NAME,
50+
} as NamedThemeConfig;
4851
};
4952

5053
export {

0 commit comments

Comments
 (0)