Compare commits

..

No commits in common. "6b7d938d89e7addbacdaea8bd4e7f3a8170e55d7" and "b3b4f7219362292d433bc5110e8a023e0d99c0bb" have entirely different histories.

View File

@ -3,10 +3,9 @@ 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');
const PER_PAGE = 8;
let currentPage = 1;
function loadLinks() { function loadLinks() {
const PER_PAGE = 8;
let currentPage = 1;
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 => {
@ -108,7 +107,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;
loadLinks(); renderPaginatedList();
reinitializeInstagramEmbeds(); reinitializeInstagramEmbeds();
} }
}) })
@ -134,7 +133,7 @@ function markLinkWatched(linkId) {
if (idx !== -1) { if (idx !== -1) {
linksData[idx] = updatedLink; linksData[idx] = updatedLink;
} }
loadLinks(); renderPaginatedList();
reinitializeInstagramEmbeds(); reinitializeInstagramEmbeds();
}) })
.catch(err => console.error(err)); .catch(err => console.error(err));
@ -156,7 +155,7 @@ addLinkBtn.addEventListener('click', () => {
linksData.push(addedLink); linksData.push(addedLink);
newLinkInput.value = ''; newLinkInput.value = '';
currentPage = 1; currentPage = 1;
loadLinks(); renderPaginatedList();
reinitializeInstagramEmbeds(); reinitializeInstagramEmbeds();
}) })
.catch(err => console.error(err)); .catch(err => console.error(err));