]>
Commit | Line | Data |
---|---|---|
ffb321be | 1 | import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants' |
7cd4d2ba C |
2 | import { PluginManager } from './plugin-manager' |
3 | import { CONFIG } from '../../initializers/config' | |
4 | ||
ffb321be | 5 | function getThemeOrDefault (name: string, defaultTheme: string) { |
7cd4d2ba C |
6 | if (isThemeRegistered(name)) return name |
7 | ||
8 | // Fallback to admin default theme | |
ffb321be | 9 | if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME) |
7cd4d2ba | 10 | |
ffb321be | 11 | return defaultTheme |
7cd4d2ba C |
12 | } |
13 | ||
14 | function isThemeRegistered (name: string) { | |
ffb321be | 15 | if (name === DEFAULT_THEME_NAME || name === DEFAULT_USER_THEME_NAME) return true |
7cd4d2ba C |
16 | |
17 | return !!PluginManager.Instance.getRegisteredThemes() | |
18 | .find(r => r.name === name) | |
19 | } | |
20 | ||
21 | export { | |
22 | getThemeOrDefault, | |
23 | isThemeRegistered | |
24 | } |