css reload fix I hope
This commit is contained in:
21
refresh.js
21
refresh.js
@@ -1,10 +1,19 @@
|
|||||||
(function () {
|
(function () {
|
||||||
const SSE_PORT = 8765;
|
const SSE_PORT = 8765;
|
||||||
const RECONNECT_DELAY = 5000; // miliseconds
|
const RECONNECT_DELAY = 5000; // milliseconds
|
||||||
|
|
||||||
let eventSource = null;
|
let eventSource = null;
|
||||||
let reconnectTimer = 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() {
|
function connect() {
|
||||||
if (reconnectTimer) {
|
if (reconnectTimer) {
|
||||||
clearTimeout(reconnectTimer);
|
clearTimeout(reconnectTimer);
|
||||||
@@ -23,8 +32,14 @@
|
|||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
if (data.type === "reload") {
|
if (data.type === "reload") {
|
||||||
console.log("Repository updated, reloading page...");
|
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) {
|
} catch (e) {
|
||||||
console.error("Error parsing SSE message:", e);
|
console.error("Error parsing SSE message:", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user