fixed problem with the browser cache that caused problems loading new files

This commit is contained in:
Nuked
2024-05-25 21:24:04 +02:00
parent 053bac146d
commit 12f688c6bf
3 changed files with 11 additions and 8 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
const cnPath="../extensions/ComfyUI-N-Sidebar/"
function addSidebarStyles(cssPath) {
const timestamp = new Date().getTime();
const linkElement = document.createElement("link");
linkElement.rel = "stylesheet";
linkElement.type = "text/css";
linkElement.href = cnPath+cssPath
linkElement.href =`${cnPath}${cssPath}?v=${timestamp}`
document.head.appendChild(linkElement);
}
+8 -6
View File
@@ -12,7 +12,8 @@ const cnPath = "../extensions/ComfyUI-N-Sidebar/"
function jsloader(url) {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = url;
const timestamp = new Date().getTime();
script.src = `${url}?v=${timestamp}`;
script.type = "text/javascript";
script.onload = () => resolve(script);
script.onerror = () => reject(new Error(`Failed to load script: ${url}`));
@@ -953,7 +954,8 @@ function processViews(viewsData, settingsData) {
await Promise.all(view.panels.map(async (panel) => {
try {
const response = await fetch(cnPath + `panels/${panel}/${panel}.html`);
const timestamp = new Date().getTime();
const response = await fetch(cnPath + `panels/${panel}/${panel}.html?v=${timestamp}`);
const html = await response.text();
if (html !== "404: Not Found") {
@@ -1046,13 +1048,13 @@ function processViews(viewsData, settingsData) {
async function loadData() {
try {
const response1 = await fetch(cnPath + 'views/views.json');
const timestamp = new Date().getTime();
const response1 = await fetch(`${cnPath}views/views.json?v=${timestamp}`);
const viewsData1 = await response1.json();
const response2 = await fetch(cnPath + 'views/custom_views.json');
const response2 = await fetch(`${cnPath}views/custom_views.json?v=${timestamp}`);
const viewsData2 = await response2.json();
const allViewsData = [...viewsData1, ...viewsData2];
const response3 = await fetch(cnPath + 'settings.json');
const response3 = await fetch(`${cnPath}settings.json?v=${timestamp}`);
const settingsData = await response3.json();
processViews(allViewsData, settingsData);
} catch (error) {
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-n-sidebar"
description = "A simple sidebar for ComfyUI."
version = "1.1.2"
version = "1.1.3"
license = "LICENSE"
[project.urls]