mirror of
https://github.com/smittix/intercept.git
synced 2026-04-25 07:10:00 -07:00
Defer hidden dashboard startup work
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
* Updater Module - GitHub update checking and notification system
|
||||
*/
|
||||
|
||||
const Updater = {
|
||||
// State
|
||||
_checkInterval: null,
|
||||
_toastElement: null,
|
||||
_modalElement: null,
|
||||
_updateData: null,
|
||||
const Updater = {
|
||||
// State
|
||||
_checkInterval: null,
|
||||
_startupCheckTimer: null,
|
||||
_toastElement: null,
|
||||
_modalElement: null,
|
||||
_updateData: null,
|
||||
|
||||
// Configuration
|
||||
CHECK_INTERVAL_MS: 6 * 60 * 60 * 1000, // 6 hours in milliseconds
|
||||
@@ -15,18 +16,31 @@ const Updater = {
|
||||
/**
|
||||
* Initialize the updater module
|
||||
*/
|
||||
init() {
|
||||
// Create toast container if it doesn't exist
|
||||
this._ensureToastContainer();
|
||||
|
||||
// Check for updates on page load
|
||||
this.checkForUpdates();
|
||||
|
||||
// Set up periodic checks
|
||||
this._checkInterval = setInterval(() => {
|
||||
this.checkForUpdates();
|
||||
}, this.CHECK_INTERVAL_MS);
|
||||
},
|
||||
init() {
|
||||
// Create toast container if it doesn't exist
|
||||
this._ensureToastContainer();
|
||||
|
||||
const enabled = localStorage.getItem('intercept_update_check_enabled') !== 'false';
|
||||
if (!enabled) {
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
// Defer the first check so the active dashboard can finish loading first.
|
||||
if (!this._startupCheckTimer) {
|
||||
this._startupCheckTimer = setTimeout(() => {
|
||||
this._startupCheckTimer = null;
|
||||
this.checkForUpdates();
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
// Set up periodic checks
|
||||
if (!this._checkInterval) {
|
||||
this._checkInterval = setInterval(() => {
|
||||
this.checkForUpdates();
|
||||
}, this.CHECK_INTERVAL_MS);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensure toast container exists in DOM
|
||||
@@ -505,11 +519,15 @@ const Updater = {
|
||||
/**
|
||||
* Clean up on page unload
|
||||
*/
|
||||
destroy() {
|
||||
if (this._checkInterval) {
|
||||
clearInterval(this._checkInterval);
|
||||
this._checkInterval = null;
|
||||
}
|
||||
destroy() {
|
||||
if (this._startupCheckTimer) {
|
||||
clearTimeout(this._startupCheckTimer);
|
||||
this._startupCheckTimer = null;
|
||||
}
|
||||
if (this._checkInterval) {
|
||||
clearInterval(this._checkInterval);
|
||||
this._checkInterval = null;
|
||||
}
|
||||
this.hideToast();
|
||||
this.hideModal();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user