css reload fix I hope
This commit is contained in:
23
refresh.js
23
refresh.js
@@ -1,10 +1,19 @@
|
||||
(function () {
|
||||
const SSE_PORT = 8765;
|
||||
const RECONNECT_DELAY = 5000; // miliseconds
|
||||
const RECONNECT_DELAY = 5000; // milliseconds
|
||||
|
||||
let eventSource = null;
|
||||
let reconnectTimer = null;
|
||||
|
||||
function reloadStylesheets() {
|
||||
// Force reload all stylesheets
|
||||
const links = document.querySelectorAll('link[rel="stylesheet"]');
|
||||
links.forEach(link => {
|
||||
const href = link.href.split('?')[0];
|
||||
link.href = href + '?t=' + new Date().getTime();
|
||||
});
|
||||
}
|
||||
|
||||
function connect() {
|
||||
if (reconnectTimer) {
|
||||
clearTimeout(reconnectTimer);
|
||||
@@ -23,8 +32,14 @@
|
||||
const data = JSON.parse(event.data);
|
||||
if (data.type === "reload") {
|
||||
console.log("Repository updated, reloading page...");
|
||||
// Hard reload to bypass cache
|
||||
window.location.reload(true);
|
||||
|
||||
// First reload stylesheets
|
||||
reloadStylesheets();
|
||||
|
||||
// Then hard reload the page after a brief delay
|
||||
setTimeout(() => {
|
||||
window.location.reload(true);
|
||||
}, 100);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error parsing SSE message:", e);
|
||||
@@ -54,4 +69,4 @@
|
||||
eventSource.close();
|
||||
}
|
||||
});
|
||||
})();
|
||||
})();
|
||||
Reference in New Issue
Block a user