Featherless: Fix model pagination init

f61c2403d66377fadcdbf5e4685ca4a4ae092651

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +7 -3Showing whitespace changes
public/scripts/textgen-models.js+7 -3
@@ -288,15 +288,19 @@ export async function loadFeatherlessModels(data) {
288 originalModels = data; // Store the original data for search288 originalModels = data; // Store the original data for search
289 featherlessModels = data;289 featherlessModels = data;
290290
291 if (!data.find(x => x.id === textgen_settings.featherless_model)) {
292 textgen_settings.featherless_model = data[0]?.id || '';
293 }
294
291 // Populate class select options with unique classes295 // Populate class select options with unique classes
292 populateClassSelection(data);296 populateClassSelection(data);
293297
294 // Retrieve the stored number of items per page or default to 5298 // Retrieve the stored number of items per page or default to 10
295 const perPage = Number(localStorage.getItem(storageKey)) || 10;299 const perPage = Number(localStorage.getItem(storageKey)) || 10;
296300
297 // Initialize pagination with the full set of models301 // Initialize pagination with the full set of models
298 const selectedModelPage = (data.findIndex(x => x.id === textgen_settings.featherless_model) / perPage) + 1;302 const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model);
299 featherlessCurrentPage = selectedModelPage > 0 ? selectedModelPage : 1;303 featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
300 setupPagination(originalModels, perPage);304 setupPagination(originalModels, perPage);
301305
302 // Function to set up pagination (also used for filtered results)306 // Function to set up pagination (also used for filtered results)