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,15 +78,30 @@ class LoraPageManager {
// Initialize common page features (lazy loading, infinite scroll) // Initialize common page features (lazy loading, infinite scroll)
appCore.initializePageFeatures(); appCore.initializePageFeatures();
} }
loadSortPreference() {
const savedSort = getStorageItem('loras_sort');
if (savedSort) {
state.sortBy = savedSort;
const sortSelect = document.getElementById('sortSelect');
if (sortSelect) {
sortSelect.value = savedSort;
}
}
} }
// Initialize event listeners saveSortPreference(sortValue) {
function initializeEventListeners() { setStorageItem('loras_sort', sortValue);
}
initEventListeners() {
const sortSelect = document.getElementById('sortSelect'); const sortSelect = document.getElementById('sortSelect');
if (sortSelect) { if (sortSelect) {
sortSelect.value = state.sortBy; sortSelect.value = state.sortBy;
this.loadSortPreference();
sortSelect.addEventListener('change', async (e) => { sortSelect.addEventListener('change', async (e) => {
state.sortBy = e.target.value; state.sortBy = e.target.value;
this.saveSortPreference(e.target.value);
await resetAndReload(); await resetAndReload();
}); });
} }
@@ -94,6 +110,7 @@ function initializeEventListeners() {
tag.addEventListener('click', toggleFolder); tag.addEventListener('click', toggleFolder);
}); });
} }
}
// Initialize everything when DOM is ready // Initialize everything when DOM is ready
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {