fix: improve release visibility and cache handling
This commit is contained in:
@@ -1023,6 +1023,8 @@
|
||||
// =====================================================
|
||||
window.ARTICLE_DATA = [];
|
||||
window.APP_CONFIG = {"forklift_rules":{"applicable_categories":["bentofix"],"rules":[{"weight_threshold_kg":1700,"max_weight_kg":2750,"requirements":{"min_core_outer_diameter_mm":170},"messages":{"en":{"warning_title":"Heavy Roll – Special Equipment Required","core_ok":"Core diameter OK (≥ 170 mm)","core_nok":"Core diameter too small"}}}],"hard_limit":{"max_weight_kg":2750,"messages":{"en":{"block_title":"Weight Limit Exceeded","block_text":"Roll weight exceeds 2750 kg maximum"}}}}};
|
||||
const ROLLCALC_ARTICLE_DATA_URL = {{ static_asset_url('article-data.json')|tojson }};
|
||||
const ROLLCALC_RECENT_CHANGES_JSON_URL = {{ static_asset_url('recent_changes.json')|tojson }};
|
||||
|
||||
// =====================================================
|
||||
// LOAD ARTICLE DATA
|
||||
@@ -1087,7 +1089,7 @@ function populateArticleDropdowns() {
|
||||
|
||||
(async function() {
|
||||
try {
|
||||
const resp = await fetch('/static/article-data.json');
|
||||
const resp = await fetch(ROLLCALC_ARTICLE_DATA_URL);
|
||||
if (resp.ok) {
|
||||
window.ARTICLE_DATA = await resp.json();
|
||||
console.log('✅ Article data loaded:', window.ARTICLE_DATA.length, 'items');
|
||||
@@ -1645,7 +1647,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
const ROLLCALC_BUILD_VERSION = {{ build_info.version|tojson }};
|
||||
const ROLLCALC_WHATS_NEW_ITEMS = {{ whats_new_summary|tojson }};
|
||||
const ROLLCALC_LAST_SEEN_VERSION_KEY = 'rollcalc_last_seen_version';
|
||||
|
||||
function shouldShowWhatsNew(currentVersion, storedVersion) {
|
||||
@@ -1675,16 +1676,41 @@ function renderWhatsNewItems(items) {
|
||||
});
|
||||
}
|
||||
|
||||
function maybeShowWhatsNew() {
|
||||
async function loadWhatsNewData(currentVersion) {
|
||||
try {
|
||||
const resp = await fetch(ROLLCALC_RECENT_CHANGES_JSON_URL);
|
||||
if (!resp.ok) {
|
||||
console.warn('Could not load RollCalc release notes summary:', resp.status);
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = await resp.json();
|
||||
if (!data || typeof data.version !== 'string' || !Array.isArray(data.items)) {
|
||||
console.warn('Invalid RollCalc release notes summary format');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.version !== currentVersion) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const items = data.items.filter(item =>
|
||||
typeof item === 'string' && item.trim()
|
||||
);
|
||||
return items.length ? { version: data.version, items } : null;
|
||||
} catch (e) {
|
||||
console.warn('Could not load RollCalc release notes summary', e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function maybeShowWhatsNew() {
|
||||
const overlay = document.getElementById('whatsNewOverlay');
|
||||
const versionValue = document.getElementById('whatsNewVersion');
|
||||
const continueBtn = document.getElementById('whatsNewContinueBtn');
|
||||
const openChangesBtn = document.getElementById('whatsNewOpenChangesBtn');
|
||||
const items = Array.isArray(ROLLCALC_WHATS_NEW_ITEMS)
|
||||
? ROLLCALC_WHATS_NEW_ITEMS
|
||||
: [];
|
||||
|
||||
if (!overlay || !versionValue || !continueBtn || !openChangesBtn || items.length === 0) return;
|
||||
if (!overlay || !versionValue || !continueBtn || !openChangesBtn) return;
|
||||
|
||||
let storedVersion = null;
|
||||
try {
|
||||
@@ -1695,8 +1721,11 @@ function maybeShowWhatsNew() {
|
||||
|
||||
if (!shouldShowWhatsNew(ROLLCALC_BUILD_VERSION, storedVersion)) return;
|
||||
|
||||
const releaseData = await loadWhatsNewData(ROLLCALC_BUILD_VERSION);
|
||||
if (!releaseData) return;
|
||||
|
||||
versionValue.textContent = ROLLCALC_BUILD_VERSION;
|
||||
renderWhatsNewItems(items);
|
||||
renderWhatsNewItems(releaseData.items);
|
||||
overlay.classList.remove('is-hidden');
|
||||
|
||||
continueBtn.addEventListener('click', () => {
|
||||
|
||||
Reference in New Issue
Block a user