Fixed display bug when selecting a model
| @@ -319,8 +319,6 @@ export async function loadFeatherlessModels(data) { | |||
| 319 | return; | 319 | return; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 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 search | 322 | originalModels = data; // Store the original data for search |
| 325 | featherlessModels = data; | 323 | featherlessModels = data; |
| 326 | 324 | ||
| @@ -334,10 +332,8 @@ export async function loadFeatherlessModels(data) { | |||
| 334 | // Retrieve the stored number of items per page or default to 10 | 332 | // 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; |
| 336 | 334 | ||
| 337 | // Initialize pagination with the full set of models | 335 | // 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); | ||
| 341 | 337 | ||
| 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 | } |
| 510 | 506 | ||
| 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 | } |
| 513 | 512 | ||