Fixed display bug when selecting a model

a06270fc858d9a51aea188a45b0fa8c37ea51b3a

Eradev <admin@eradev.com>

1 files changed, +5 -6Showing whitespace changes
public/scripts/textgen-models.js+5 -6
@@ -319,8 +319,6 @@ export async function loadFeatherlessModels(data) {
319 return;319 return;
320 }320 }
321321
322 // Sort the data by model id (default A-Z)
323 data.sort((a, b) => a.id.localeCompare(b.id));
324 originalModels = data; // Store the original data for search322 originalModels = data; // Store the original data for search
325 featherlessModels = data;323 featherlessModels = data;
326324
@@ -334,10 +332,8 @@ export async function loadFeatherlessModels(data) {
334 // Retrieve the stored number of items per page or default to 10332 // Retrieve the stored number of items per page or default to 10
335 const perPage = Number(localStorage.getItem(storageKey)) || 10;333 const perPage = Number(localStorage.getItem(storageKey)) || 10;
336334
337 // Initialize pagination with the full set of models335 // Initialize pagination
338 const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model);336 applyFiltersAndSort();
339 featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
340 setupPagination(originalModels, perPage);
341337
342 // Function to set up pagination (also used for filtered results)338 // Function to set up pagination (also used for filtered results)
343 function setupPagination(models, perPage, pageNumber = featherlessCurrentPage) {339 function setupPagination(models, perPage, pageNumber = featherlessCurrentPage) {
@@ -508,6 +504,9 @@ export async function loadFeatherlessModels(data) {
508 filteredModels.sort((a, b) => b.created - a.created);504 filteredModels.sort((a, b) => b.created - a.created);
509 }505 }
510506
507 const currentModelIndex = filteredModels.findIndex(x => x.id === textgen_settings.featherless_model);
508 featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
509
511 setupPagination(filteredModels, Number(localStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);510 setupPagination(filteredModels, Number(localStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);
512 }511 }
513512