From 5ee173c2f6b66115dcbb3e1660ca76adcecf9c84 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 21 Jan 2019 14:16:06 -0500 Subject: [PATCH] fix: #7276 improper request for client-noskin.css --- public/src/app.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index bf68b520c8..4e30cc7c32 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -149,7 +149,7 @@ app.cacheBuster = null; Unread.initUnreadTopics(); Notifications.prepareDOM(); Chat.prepareDOM(); - app.reskin(data.config.bootswatchSkin); + app.reskin(data.header.bootswatchSkin); translator.switchTimeagoLanguage(callback); bootbox.setLocale(config.userLang); @@ -770,6 +770,17 @@ app.cacheBuster = null; return; } + var currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) { + return className.startsWith('skin-'); + }); + var currentSkin = currentSkinClassName[0].slice(5); + currentSkin = currentSkin !== 'noskin' ? currentSkin : ''; + + // Stop execution if skin didn't change + if (skinName === currentSkin) { + return; + } + var linkEl = document.createElement('link'); linkEl.rel = 'stylesheet'; linkEl.type = 'text/css'; @@ -778,13 +789,8 @@ app.cacheBuster = null; clientEl.parentNode.removeChild(clientEl); // Update body class with proper skin name - var currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) { - return className.startsWith('skin-'); - }); $('body').removeClass(currentSkinClassName.join(' ')); - if (skinName) { - $('body').addClass('skin-' + skinName); - } + $('body').addClass('skin-' + (skinName || 'noskin')); }; document.head.appendChild(linkEl);