-
🌐 async-utils.jsWeb, 3.69 kB⬇
-
🌐 auth-storage.jsWeb, 735 B⬇
-
🌐 chat-helpers.jsWeb, 8.85 kB⬇
-
🌐 chat-renderer.jsWeb, 70.00 kB⬇
-
🌐 code-overlay.jsWeb, 21.77 kB⬇
-
🌐 confirm-dialog.jsWeb, 3.17 kB⬇
-
🌐 conversation-format-utils.jsWeb, 21.51 kB⬇
-
🌐 diagram-overlay.jsWeb, 7.93 kB⬇
-
🌐 dialog.jsWeb, 2.50 kB⬇
-
🌐 dom-utils.jsWeb, 8.33 kB⬇
-
🌐 drag-reorder.jsWeb, 4.82 kB⬇
-
🌐 elements.jsWeb, 11.06 kB⬇
-
🌐 export-utils.jsWeb, 1.53 kB⬇
-
🌐 format-utils.jsWeb, 29.60 kB⬇
-
🌐 history-navigation.jsWeb, 1.95 kB⬇
-
🌐 hljs-yaml.jsWeb, 5.07 kB⬇
-
🌐 inline-format.jsWeb, 7.35 kB⬇
-
🌐 instant-answer.jsWeb, 19.82 kB⬇
-
🌐 interactive-tools.jsWeb, 38.77 kB⬇
-
🌐 mermaid-fixes.jsWeb, 4.60 kB⬇
-
🌐 mermaid-render.jsWeb, 5.10 kB⬇
-
🌐 mermaid.jsWeb, 195 B⬇
-
🌐 migrations.jsWeb, 12.11 kB⬇
-
🌐 multi-choice-dialog.jsWeb, 1.33 kB⬇
-
🌐 notification-stack.jsWeb, 2.50 kB⬇
-
🌐 options-manager.jsWeb, 45.56 kB⬇
-
🌐 overlay-utils.jsWeb, 4.14 kB⬇
-
🌐 pdf-export.jsWeb, 23.59 kB⬇
-
🌐 pinch-zoom.jsWeb, 3.21 kB⬇
-
🌐 plugin-dialog.jsWeb, 2.17 kB⬇
-
🌐 read-aloud.jsWeb, 33.84 kB⬇
-
🌐 response-pipeline.jsWeb, 55.19 kB⬇
-
🌐 scratchpad-editor.jsWeb, 8.64 kB⬇
-
🌐 scratchpad-export.jsWeb, 3.56 kB⬇
-
🌐 scrollbars.jsWeb, 3.12 kB⬇
-
🌐 selection-manager.jsWeb, 3.76 kB⬇
-
🌐 settings-utils.jsWeb, 31.08 kB⬇
-
🌐 share.jsWeb, 10.75 kB⬇
-
🌐 side-drawer.jsWeb, 9.37 kB⬇
-
🌐 speech-text.jsWeb, 6.60 kB⬇
-
🌐 swipe-navigation.jsWeb, 6.16 kB⬇
-
🌐 table-overlay.jsWeb, 8.10 kB⬇
-
🌐 theme-utils.jsWeb, 8.34 kB⬇
-
🌐 thinking-panel-base.jsWeb, 14.88 kB⬇
-
🌐 ui-sets.jsWeb, 1.00 kB⬇
-
🌐 version-overlay.jsWeb, 4.63 kB⬇
import { showOverlay, hideOverlay } from './overlay-utils.js';
import { formatVersionHeader, formatChangelogItem } from './settings-utils.js';
/** @typedef {import('../app.js').default} App */
/**
* Manages the app version check, the version section in the settings form, and the changelog overlay.
*/
class VersionOverlay {
#app_version_data = null;
/**
* @param {App} app - The main application instance.
*/
constructor(app) {
this.app = app;
}
/**
* Checks the latest app version against stored version and shows changelog overlay if newer.
* Also populates version information in application settings.
* @returns {Promise<void>}
*/
async init_version_check() {
try {
const versionData = await this.app.api.get_version();
if (!versionData || versionData.error) return;
this.#app_version_data = versionData;
this.update_app_version_settings(versionData);
const latestDate = versionData['version-date'];
if (!latestDate) return;
const storedDate = this.app.storage.get_stored_version_date();
if (!storedDate || String(latestDate) > String(storedDate)) {
await this.show_version_overlay();
this.app.storage.set_stored_version_date(latestDate);
}
} catch (error) {
console.error('Failed to check app version:', error);
}
}
/**
* Loads the cached version data or fetches it, updating the settings display.
* @returns {Promise<void>}
*/
async ensure_version_loaded() {
if (this.#app_version_data) {
this.update_app_version_settings(this.#app_version_data);
return;
}
try {
const versionData = await this.app.api.get_version();
if (versionData && !versionData.error) {
this.#app_version_data = versionData;
this.update_app_version_settings(versionData);
}
} catch (error) {
console.error('Failed to load version for settings:', error);
}
}
/**
* Populates the version section in the application settings form.
* @param {Object} versionData - Latest version object.
*/
update_app_version_settings(versionData) {
if (!versionData) return;
if (this.app.div_app_version_title) {
this.app.div_app_version_title.textContent = formatVersionHeader(versionData);
}
if (this.app.div_app_version_description) {
this.app.div_app_version_description.textContent = versionData['version-description'] || '';
}
}
/**
* Shows the full version overlay with current and previous version changelogs.
* @returns {Promise<void>}
*/
async show_version_overlay() {
if (!this.app.div_version_overlay) return;
try {
const response = await this.app.api.get_version(2);
const versions = response?.versions || (response ? [response] : []);
this.render_version_overlay_content(versions);
showOverlay(this.app.div_version_overlay);
} catch (error) {
console.error('Failed to load full version information:', error);
}
}
/**
* Hides the full version overlay modal.
*/
hide_version_overlay() {
if (this.app.div_version_overlay) {
hideOverlay(this.app.div_version_overlay);
}
}
/**
* Renders current and previous version details into the version overlay container.
* @param {Array<Object>} versions - Array of version data objects.
*/
render_version_overlay_content(versions) {
if (!this.app.div_version_content) return;
if (!Array.isArray(versions) || versions.length === 0) {
this.app.div_version_content.innerHTML = '<p>No version information available.</p>';
return;
}
const current = versions[0];
const previous = versions.length > 1 ? versions[1] : null;
let html = '';
if (current) {
html += `<fieldset class="div-version-section">
<legend>Current Version</legend>
<p style="font-weight: bold; margin-bottom: 4px;">${formatVersionHeader(current)}</p>
<p style="margin-bottom: 8px;">${current['version-description'] || ''}</p>`;
if (Array.isArray(current.changelog) && current.changelog.length > 0) {
html += `<ul>`;
current.changelog.forEach(item => {
html += `<li>${formatChangelogItem(item)}</li>`;
});
html += `</ul>`;
}
html += `</fieldset>`;
}
if (previous) {
html += `<fieldset class="div-version-section" style="margin-top: 15px;">
<legend>Previous Version</legend>
<p style="font-weight: bold; margin-bottom: 4px;">${formatVersionHeader(previous)}</p>
<p style="margin-bottom: 8px;">${previous['version-description'] || ''}</p>`;
if (Array.isArray(previous.changelog) && previous.changelog.length > 0) {
html += `<ul>`;
previous.changelog.forEach(item => {
html += `<li>${formatChangelogItem(item)}</li>`;
});
html += `</ul>`;
}
html += `</fieldset>`;
}
this.app.div_version_content.innerHTML = html;
}
}
export default VersionOverlay;
version-overlay.js
×
Type: Web, text/plain
4.63 Kilobytes
Last Modified 2026-11-04 09:48:28
⬇ Download File
Type: Web, text/plain
4.63 Kilobytes
Last Modified 2026-11-04 09:48:28
⬇ Download File