mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 06:32:12 -03:00
Enhance settings management and localStorage integration
- Added functionality to load settings from localStorage in the SettingsManager, ensuring user preferences are retained across sessions. - Updated the state management to initialize settings from localStorage, improving user experience. - Refactored the UpdateService to streamline update notification preferences. - Improved migration logic in storageHelpers to prevent duplicate migrations and ensure data integrity. - Removed unnecessary console logs for cleaner output in various modules.
This commit is contained in:
@@ -74,6 +74,12 @@ export function removeStorageItem(key) {
|
||||
* This should be called once during application initialization
|
||||
*/
|
||||
export function migrateStorageItems() {
|
||||
// Check if migration has already been performed
|
||||
if (localStorage.getItem(STORAGE_PREFIX + 'migration_completed')) {
|
||||
console.log('Lora Manager: Storage migration already completed');
|
||||
return;
|
||||
}
|
||||
|
||||
// List of known keys used in the application
|
||||
const knownKeys = [
|
||||
'nsfwBlurLevel',
|
||||
@@ -93,18 +99,29 @@ export function migrateStorageItems() {
|
||||
|
||||
// Migrate each known key
|
||||
knownKeys.forEach(key => {
|
||||
const value = localStorage.getItem(key);
|
||||
if (value !== null) {
|
||||
try {
|
||||
// Try to parse as JSON first
|
||||
const parsedValue = JSON.parse(value);
|
||||
setStorageItem(key, parsedValue);
|
||||
} catch (e) {
|
||||
// If not JSON, store as is
|
||||
setStorageItem(key, value);
|
||||
const prefixedKey = STORAGE_PREFIX + key;
|
||||
|
||||
// Only migrate if the prefixed key doesn't already exist
|
||||
if (localStorage.getItem(prefixedKey) === null) {
|
||||
const value = localStorage.getItem(key);
|
||||
if (value !== null) {
|
||||
try {
|
||||
// Try to parse as JSON first
|
||||
const parsedValue = JSON.parse(value);
|
||||
setStorageItem(key, parsedValue);
|
||||
} catch (e) {
|
||||
// If not JSON, store as is
|
||||
setStorageItem(key, value);
|
||||
}
|
||||
|
||||
// We can optionally remove the old key after migration
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Mark migration as completed
|
||||
localStorage.setItem(STORAGE_PREFIX + 'migration_completed', 'true');
|
||||
|
||||
console.log('Lora Manager: Storage migration completed');
|
||||
}
|
||||
@@ -177,7 +177,7 @@ export function toggleFolderTags() {
|
||||
|
||||
// Add this to your existing initialization code
|
||||
export function initFolderTagsVisibility() {
|
||||
const isCollapsed = getStorageItem('folderTagsCollapsed') === 'true';
|
||||
const isCollapsed = getStorageItem('folderTagsCollapsed');
|
||||
if (isCollapsed) {
|
||||
const folderTags = document.querySelector('.folder-tags');
|
||||
const toggleBtn = document.querySelector('.toggle-folders-btn i');
|
||||
|
||||
Reference in New Issue
Block a user