Fix issues with selecting the correct theme
This commit is contained in:
parent
96c8a25f83
commit
b10548840a
|
@ -50,9 +50,9 @@ exports.ThemeManager = class ThemeManager {
|
||||||
themeManagerInstance
|
themeManagerInstance
|
||||||
.getAvailableThemes()
|
.getAvailableThemes()
|
||||||
.forEach((themeConfig, themeId) => {
|
.forEach((themeConfig, themeId) => {
|
||||||
const { name, author, group, acs } = themeConfig.get().info;
|
const { name, author, group } = themeConfig.get().info;
|
||||||
Log.info(
|
Log.info(
|
||||||
{ themeId, themeName: name, author: author, group: group, acs: acs },
|
{ themeId, themeName: name, author, group },
|
||||||
'Theme loaded'
|
'Theme loaded'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -431,8 +431,8 @@ function selectDefaultTheme(client) {
|
||||||
function themeAcsMatches(client, themeName) {
|
function themeAcsMatches(client, themeName) {
|
||||||
const themeConfig = getAvailableThemes().get(themeName);
|
const themeConfig = getAvailableThemes().get(themeName);
|
||||||
if (!_.isNil(themeConfig)) {
|
if (!_.isNil(themeConfig)) {
|
||||||
if (_.has(themeConfig, 'info.acs')) {
|
if (_.has(themeConfig, 'current.info.acs')) {
|
||||||
return client.acs.matches(themeConfig.info.acs);
|
return client.acs.matches(themeConfig.current.info.acs);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -464,18 +464,13 @@ function setClientTheme(client, themeId) {
|
||||||
|
|
||||||
let msg;
|
let msg;
|
||||||
let setThemeId;
|
let setThemeId;
|
||||||
const config = Config();
|
|
||||||
const defaultTheme = selectDefaultTheme(client);
|
const defaultTheme = selectDefaultTheme(client);
|
||||||
if (availThemes.has(themeId)) {
|
if (availThemes.has(themeId) && themeAcsMatches(client, themeId)) {
|
||||||
msg = 'Set client theme';
|
msg = 'Set client theme';
|
||||||
setThemeId = themeAcsMatches(client, themeId);
|
setThemeId = themeId;
|
||||||
if (_.isNil(setThemeId)) {
|
|
||||||
Log.warn('No theme matching acs found, setting to first theme.');
|
|
||||||
setThemeId = availThemes.keys().next().value;
|
|
||||||
}
|
|
||||||
} else if (availThemes.has(defaultTheme)) {
|
} else if (availThemes.has(defaultTheme)) {
|
||||||
msg = 'Failed setting theme by supplied ID; Using default';
|
msg = 'Failed setting theme by supplied ID; Using default';
|
||||||
setThemeId = findMatching(client, config.theme.default);
|
setThemeId = defaultTheme;
|
||||||
if (_.isNil(setThemeId)) {
|
if (_.isNil(setThemeId)) {
|
||||||
Log.warn('No theme matching acs found, setting to first theme.');
|
Log.warn('No theme matching acs found, setting to first theme.');
|
||||||
setThemeId = availThemes.keys().next().value;
|
setThemeId = availThemes.keys().next().value;
|
||||||
|
@ -506,15 +501,16 @@ function getThemeArt(options, cb) {
|
||||||
// random
|
// random
|
||||||
//
|
//
|
||||||
const config = Config();
|
const config = Config();
|
||||||
if (
|
if ( !options.themeId) {
|
||||||
!options.themeId &&
|
if(_.has(options, ['client','currentTheme','info','themeId'])) {
|
||||||
_.has(options, ['client', 'user', 'properties', UserProps.ThemeId])
|
options.themeId = options.client.currentTheme.info.themeId;
|
||||||
) {
|
}
|
||||||
options.themeId = options.client.user.properties[UserProps.ThemeId];
|
else if(_.has(options, ['client', 'user', 'properties', UserProps.ThemeId])) {
|
||||||
}
|
options.themeId = options.client.user.properties[UserProps.ThemeId];
|
||||||
|
}
|
||||||
if (!options.themeId) {
|
else {
|
||||||
options.themeId = this.selectDefaultTheme(options.client);
|
options.themeId = selectDefaultTheme(options.client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ...
|
// :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ...
|
||||||
|
|
Loading…
Reference in New Issue