SHA256
UI: исправить автообновление и хронологию диалогов; обновить деплой-цели
This commit is contained in:
+45
-8
@@ -105,6 +105,7 @@ const appShellEl = document.querySelector('.app-shell');
|
||||
|
||||
const CONNECTION_CHECK_INTERVAL_MS = 20 * 1000;
|
||||
const CURRENT_BUILD_HASH = String(window.__SHINE_BUILD_HASH__ || '').trim();
|
||||
const UI_BUILD_HASH_PATTERN = /window\.__SHINE_BUILD_HASH__\s*=\s*'([^']+)'/;
|
||||
|
||||
let currentCleanup = null;
|
||||
let pingIntervalId = null;
|
||||
@@ -119,6 +120,7 @@ let connectionCheckInFlight = false;
|
||||
let wsSessionRestoreInFlight = null;
|
||||
let uiUpdateReloadScheduled = false;
|
||||
let pwaUpdateCheckAttempted = false;
|
||||
let uiVersionCheckInFlight = false;
|
||||
|
||||
setClientErrorTransport((payload) => authService.reportClientError(payload));
|
||||
initPwaInstallPromptHandling();
|
||||
@@ -235,16 +237,51 @@ async function triggerImmediateConnectionRetry() {
|
||||
await checkConnectionHealth();
|
||||
}
|
||||
|
||||
function checkAndReloadIfUiUpdated(remoteHashRaw) {
|
||||
function extractBuildHashFromHtml(htmlText) {
|
||||
const html = String(htmlText || '');
|
||||
if (!html) return '';
|
||||
const match = html.match(UI_BUILD_HASH_PATTERN);
|
||||
return String(match?.[1] || '').trim();
|
||||
}
|
||||
|
||||
async function fetchCurrentHostUiBuildHash() {
|
||||
try {
|
||||
const url = `./index.html?build_probe=${Date.now()}`;
|
||||
const response = await fetch(url, { cache: 'no-store' });
|
||||
if (!response?.ok) return '';
|
||||
const html = await response.text();
|
||||
return extractBuildHashFromHtml(html);
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAndReloadIfUiUpdated(remoteHashRaw) {
|
||||
const remoteHash = String(remoteHashRaw || '').trim();
|
||||
if (!remoteHash || !CURRENT_BUILD_HASH || remoteHash === CURRENT_BUILD_HASH) return;
|
||||
if (uiVersionCheckInFlight) return;
|
||||
|
||||
scheduleUiReload({
|
||||
source: 'version-check',
|
||||
message: `Обнаружена новая версия UI (через Ping): ${CURRENT_BUILD_HASH} -> ${remoteHash}`,
|
||||
delayMs: 600,
|
||||
activateWaitingWorker: true,
|
||||
});
|
||||
uiVersionCheckInFlight = true;
|
||||
try {
|
||||
const latestHostHash = await fetchCurrentHostUiBuildHash();
|
||||
if (!latestHostHash || latestHostHash === CURRENT_BUILD_HASH) {
|
||||
addAppLogEntry({
|
||||
level: 'info',
|
||||
source: 'version-check',
|
||||
message: `Ping сообщил другую версию UI (${remoteHash}), но текущий хост всё ещё отдаёт ${CURRENT_BUILD_HASH}. Reload пропущен, чтобы избежать цикла.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
scheduleUiReload({
|
||||
source: 'version-check',
|
||||
message: `Обнаружена новая версия UI: ${CURRENT_BUILD_HASH} -> ${latestHostHash} (ping: ${remoteHash})`,
|
||||
delayMs: 600,
|
||||
activateWaitingWorker: true,
|
||||
});
|
||||
} finally {
|
||||
uiVersionCheckInFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshServiceWorkers({ activateWaitingWorker = false } = {}) {
|
||||
@@ -313,7 +350,7 @@ async function checkConnectionHealth() {
|
||||
}
|
||||
const pingResp = await authService.ws.request('Ping', { ts: Date.now() }, 7000);
|
||||
const remoteUiBuildHash = pingResp?.payload?.uiBuildHash || pingResp?.uiBuildHash || '';
|
||||
checkAndReloadIfUiUpdated(remoteUiBuildHash);
|
||||
void checkAndReloadIfUiUpdated(remoteUiBuildHash);
|
||||
await tryUpdatePwaOnFirstConnectedPing();
|
||||
setConnectionStatus('connected');
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user