Skip to content

Commit

Permalink
fixed problem with the browser cache that caused problems loading new…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
Nuked88 committed May 25, 2024
1 parent 053bac1 commit 12f688c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/js/functions/sb_fn.js
Original file line number Diff line number Diff line change
@@ -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);
}

Expand Down
14 changes: 8 additions & 6 deletions app/js/sidebar_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`));
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit 12f688c

Please sign in to comment.