Remember sort by name/date in LoRAs page

This commit is contained in:
Richard Hristov
2025-03-29 17:11:53 +02:00
parent c31c9c16cf
commit e7871bf843

View File

@@ -17,6 +17,7 @@ import { LoraContextMenu } from './components/ContextMenu.js';
import { moveManager } from './managers/MoveManager.js'; import { moveManager } from './managers/MoveManager.js';
import { updateCardsForBulkMode } from './components/LoraCard.js'; import { updateCardsForBulkMode } from './components/LoraCard.js';
import { bulkManager } from './managers/BulkManager.js'; import { bulkManager } from './managers/BulkManager.js';
import { setStorageItem, getStorageItem } from './utils/storageHelpers.js';
// Initialize the LoRA page // Initialize the LoRA page
class LoraPageManager { class LoraPageManager {
@@ -63,7 +64,7 @@ class LoraPageManager {
async initialize() { async initialize() {
// Initialize page-specific components // Initialize page-specific components
initializeEventListeners(); this.initEventListeners();
restoreFolderFilter(); restoreFolderFilter();
initFolderTagsVisibility(); initFolderTagsVisibility();
new LoraContextMenu(); new LoraContextMenu();
@@ -77,22 +78,38 @@ class LoraPageManager {
// Initialize common page features (lazy loading, infinite scroll) // Initialize common page features (lazy loading, infinite scroll)
appCore.initializePageFeatures(); appCore.initializePageFeatures();
} }
}
// Initialize event listeners loadSortPreference() {
function initializeEventListeners() { const savedSort = getStorageItem('loras_sort');
const sortSelect = document.getElementById('sortSelect'); if (savedSort) {
if (sortSelect) { state.sortBy = savedSort;
sortSelect.value = state.sortBy; const sortSelect = document.getElementById('sortSelect');
sortSelect.addEventListener('change', async (e) => { if (sortSelect) {
state.sortBy = e.target.value; sortSelect.value = savedSort;
await resetAndReload(); }
}); }
} }
document.querySelectorAll('.folder-tags .tag').forEach(tag => { saveSortPreference(sortValue) {
tag.addEventListener('click', toggleFolder); setStorageItem('loras_sort', sortValue);
}); }
initEventListeners() {
const sortSelect = document.getElementById('sortSelect');
if (sortSelect) {
sortSelect.value = state.sortBy;
this.loadSortPreference();
sortSelect.addEventListener('change', async (e) => {
state.sortBy = e.target.value;
this.saveSortPreference(e.target.value);
await resetAndReload();
});
}
document.querySelectorAll('.folder-tags .tag').forEach(tag => {
tag.addEventListener('click', toggleFolder);
});
}
} }
// Initialize everything when DOM is ready // Initialize everything when DOM is ready