mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 23:25:43 -03:00
Refactor storage handling across application
- Introduced a new storageHelpers module to centralize localStorage interactions, improving code maintainability and readability. - Updated various components and managers to utilize the new storageHelpers functions for setting, getting, and removing items from localStorage. - Added migration logic to handle localStorage items during application initialization, ensuring compatibility with the new storage structure. - Enhanced logging during application initialization for better debugging.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { modalManager } from './ModalManager.js';
|
||||
import { getStorageItem, setStorageItem } from '../utils/storageHelpers.js';
|
||||
|
||||
export class UpdateService {
|
||||
constructor() {
|
||||
@@ -7,13 +8,13 @@ export class UpdateService {
|
||||
this.latestVersion = "v0.0.0"; // Initialize with default values
|
||||
this.updateInfo = null;
|
||||
this.updateAvailable = false;
|
||||
this.updateNotificationsEnabled = localStorage.getItem('show_update_notifications') !== 'false';
|
||||
this.lastCheckTime = parseInt(localStorage.getItem('last_update_check') || '0');
|
||||
this.updateNotificationsEnabled = getStorageItem('show_update_notifications') !== 'false';
|
||||
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
|
||||
}
|
||||
|
||||
initialize() {
|
||||
// Initialize update preferences from localStorage
|
||||
const showUpdates = localStorage.getItem('show_update_notifications');
|
||||
const showUpdates = getStorageItem('show_update_notifications');
|
||||
this.updateNotificationsEnabled = showUpdates === null || showUpdates === 'true';
|
||||
|
||||
// Register event listener for update notification toggle
|
||||
@@ -22,7 +23,7 @@ export class UpdateService {
|
||||
updateCheckbox.checked = this.updateNotificationsEnabled;
|
||||
updateCheckbox.addEventListener('change', (e) => {
|
||||
this.updateNotificationsEnabled = e.target.checked;
|
||||
localStorage.setItem('show_update_notifications', e.target.checked);
|
||||
setStorageItem('show_update_notifications', e.target.checked);
|
||||
this.updateBadgeVisibility();
|
||||
});
|
||||
}
|
||||
@@ -71,7 +72,7 @@ export class UpdateService {
|
||||
|
||||
// Update last check time
|
||||
this.lastCheckTime = now;
|
||||
localStorage.setItem('last_update_check', now.toString());
|
||||
setStorageItem('last_update_check', now.toString());
|
||||
|
||||
// Update UI
|
||||
this.updateBadgeVisibility();
|
||||
|
||||
Reference in New Issue
Block a user