Fixed display bug when selecting a model

This commit is contained in:
Eradev
2025-01-15 08:04:15 -05:00
parent c1535f1b34
commit a06270fc85

View File

@@ -319,8 +319,6 @@ export async function loadFeatherlessModels(data) {
return; return;
} }
// Sort the data by model id (default A-Z)
data.sort((a, b) => a.id.localeCompare(b.id));
originalModels = data; // Store the original data for search originalModels = data; // Store the original data for search
featherlessModels = data; featherlessModels = data;
@@ -334,10 +332,8 @@ export async function loadFeatherlessModels(data) {
// Retrieve the stored number of items per page or default to 10 // Retrieve the stored number of items per page or default to 10
const perPage = Number(localStorage.getItem(storageKey)) || 10; const perPage = Number(localStorage.getItem(storageKey)) || 10;
// Initialize pagination with the full set of models // Initialize pagination
const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model); applyFiltersAndSort();
featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
setupPagination(originalModels, perPage);
// Function to set up pagination (also used for filtered results) // Function to set up pagination (also used for filtered results)
function setupPagination(models, perPage, pageNumber = featherlessCurrentPage) { function setupPagination(models, perPage, pageNumber = featherlessCurrentPage) {
@@ -508,6 +504,9 @@ export async function loadFeatherlessModels(data) {
filteredModels.sort((a, b) => b.created - a.created); filteredModels.sort((a, b) => b.created - a.created);
} }
const currentModelIndex = filteredModels.findIndex(x => x.id === textgen_settings.featherless_model);
featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
setupPagination(filteredModels, Number(localStorage.getItem(storageKey)) || perPage, featherlessCurrentPage); setupPagination(filteredModels, Number(localStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);
} }