fix: closes #11954, fix custom skins with spaces

isekai-main
Barış Soner Uşaklı 1 year ago
parent 9d6aeba376
commit 965780b731

@ -2,8 +2,8 @@
define('admin/appearance/skins', [
'translator', 'alerts', 'settings', 'hooks',
], function (translator, alerts, settings, hooks) {
'translator', 'alerts', 'settings', 'hooks', 'slugify',
], function (translator, alerts, settings, hooks, slugify) {
const Skins = {};
Skins.init = function () {
@ -14,9 +14,9 @@ define('admin/appearance/skins', [
}).done((bsData) => {
hooks.on('action:settings.sorted-list.loaded', (data) => {
if (data.hash === 'custom-skins') {
// lower case all custom-skin ids after load
// slugify all custom-skin ids after load
$('.custom-skin-settings [data-type="list"] [data-theme]').each((i, el) => {
$(el).attr('data-theme', $(el).attr('data-theme').toLowerCase());
$(el).attr('data-theme', slugify($(el).attr('data-theme')));
});
highlightSelectedTheme(app.config.bootswatchSkin);
}

@ -260,7 +260,11 @@ CSS.getSkinSwitcherOptions = async function (uid) {
CSS.getCustomSkins(),
]);
const defaultSkin = _.capitalize(meta.config.bootswatchSkin) || '[[user:no-skin]]';
const foundCustom = customSkins.find(skin => skin.value === meta.config.bootswatchSkin);
const defaultSkin = foundCustom ?
foundCustom.name :
_.capitalize(meta.config.bootswatchSkin) || '[[user:no-skin]]';
const defaultSkins = [
{ name: `[[user:default, ${defaultSkin}]]`, value: '', selected: userSettings.bootswatchSkin === '' },
{ name: '[[user:no-skin]]', value: 'noskin', selected: userSettings.bootswatchSkin === 'noskin' },

Loading…
Cancel
Save