Skip to content

Commit

Permalink
fix: pagination controls by ensuring activation post outbox URL updat…
Browse files Browse the repository at this point in the history
…e in actor-profile
  • Loading branch information
akhileshthite committed Mar 19, 2024
1 parent 6423106 commit 128d062
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions actor-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ActorProfile extends HTMLElement {
"url",
actorInfo.outbox
);
this.dispatchEvent(new CustomEvent('outboxUpdated', { bubbles: true }));
}
}

Expand Down
2 changes: 1 addition & 1 deletion outbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class DistributedOutbox extends HTMLElement {
constructor() {
super();
this.renderedItems = new Map(); // Tracks rendered items by ID
this.numPosts = 32; // Default value
this.numPosts = 1; // Default value
this.page = 1; // Default value
this.totalPages = 0; // Keep track of total pages
}
Expand Down
20 changes: 11 additions & 9 deletions profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
<button id="nextPage">Next ></button>
</div>
<script>
const outboxElement = document.querySelector("distributed-outbox");
const prevButton = document.getElementById("prevPage");
const nextButton = document.getElementById("nextPage");
document.addEventListener("outboxUpdated", () => {
const outboxElement = document.querySelector("distributed-outbox");
const prevButton = document.getElementById("prevPage");
const nextButton = document.getElementById("nextPage");

if (prevButton) {
prevButton.addEventListener("click", () => outboxElement.prevPage());
}
if (nextButton) {
nextButton.addEventListener("click", () => outboxElement.nextPage());
}
if (prevButton) {
prevButton.addEventListener("click", () => outboxElement.prevPage());
}
if (nextButton) {
nextButton.addEventListener("click", () => outboxElement.nextPage());
}
});
</script>
<script>
const params = new URLSearchParams(window.location.search);
Expand Down

0 comments on commit 128d062

Please sign in to comment.