Compare commits

...

4 Commits

Author SHA1 Message Date
Олег Водянов
6b7d938d89
Merge pull request #20 from olegvodyanov/add_pagination
All checks were successful
continuous-integration/drone/push Build is passing
fix
2025-04-23 10:57:00 +04:00
oleg.vodyanov91@gmail.com
fd5929f735 fix 2025-04-23 10:56:32 +04:00
Олег Водянов
7347beda9e
Merge pull request #19 from olegvodyanov/add_pagination
fix
2025-04-23 10:49:51 +04:00
oleg.vodyanov91@gmail.com
1b57db3fb1 fix 2025-04-23 10:49:25 +04:00

View File

@ -3,9 +3,10 @@ const addLinkBtn = document.getElementById('addLinkBtn');
const newLinksContainer = document.getElementById('newLinksContainer'); const newLinksContainer = document.getElementById('newLinksContainer');
const watchedLinksContainer = document.getElementById('watchedLinksContainer'); const watchedLinksContainer = document.getElementById('watchedLinksContainer');
function loadLinks() {
const PER_PAGE = 8; const PER_PAGE = 8;
let currentPage = 1; let currentPage = 1;
function loadLinks() {
fetch(`/api/links/?page=${currentPage}&per_page=${PER_PAGE}`) fetch(`/api/links/?page=${currentPage}&per_page=${PER_PAGE}`)
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
@ -107,7 +108,7 @@ function deleteLink(linkId) {
if (res.ok) { if (res.ok) {
linksData = linksData.filter(link => link.id !== linkId); linksData = linksData.filter(link => link.id !== linkId);
currentPage = 1; currentPage = 1;
renderPaginatedList(); loadLinks();
reinitializeInstagramEmbeds(); reinitializeInstagramEmbeds();
} }
}) })
@ -133,7 +134,7 @@ function markLinkWatched(linkId) {
if (idx !== -1) { if (idx !== -1) {
linksData[idx] = updatedLink; linksData[idx] = updatedLink;
} }
renderPaginatedList(); loadLinks();
reinitializeInstagramEmbeds(); reinitializeInstagramEmbeds();
}) })
.catch(err => console.error(err)); .catch(err => console.error(err));
@ -155,7 +156,7 @@ addLinkBtn.addEventListener('click', () => {
linksData.push(addedLink); linksData.push(addedLink);
newLinkInput.value = ''; newLinkInput.value = '';
currentPage = 1; currentPage = 1;
renderPaginatedList(); loadLinks();
reinitializeInstagramEmbeds(); reinitializeInstagramEmbeds();
}) })
.catch(err => console.error(err)); .catch(err => console.error(err));