diff --git a/static/js/api/loraApi.js b/static/js/api/loraApi.js new file mode 100644 index 00000000..3dae5e81 --- /dev/null +++ b/static/js/api/loraApi.js @@ -0,0 +1,238 @@ +import { state } from '../state/index.js'; +import { showToast } from '../utils/uiHelpers.js'; +import { createLoraCard } from '../components/LoraCard.js'; +import { initializeInfiniteScroll } from '../utils/infiniteScroll.js'; +import { showDeleteModal } from '../utils/modalUtils.js'; + +export async function loadMoreLoras() { + if (state.isLoading || !state.hasMore) return; + + state.isLoading = true; + try { + const params = new URLSearchParams({ + page: state.currentPage, + page_size: 20, + sort_by: state.sortBy + }); + + if (state.activeFolder !== null) { + params.append('folder', state.activeFolder); + } + + console.log('Loading loras with params:', params.toString()); + + const response = await fetch(`/api/loras?${params}`); + if (!response.ok) { + throw new Error(`Failed to fetch loras: ${response.statusText}`); + } + + const data = await response.json(); + console.log('Received data:', data); + + if (data.items.length === 0 && state.currentPage === 1) { + const grid = document.getElementById('loraGrid'); + grid.innerHTML = '