Skip to content

Commit

Permalink
fix: #135
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieHz committed Jan 10, 2025
1 parent fe90bdc commit 8e67f32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions templates/moment.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@
likedMomentNames = [...likedMomentNames, momentName];
localStorage.setItem(likes_localstorage_key, JSON.stringify(likedMomentNames));
const likesNode = document.querySelector('span[data-moment-name="' + momentName + '"]');
const likes = parseInt(likesNode.innerText);
likesNode.innerText = likes + 1;
if (likesNode) {
const likes = parseInt(likesNode.innerText);
likesNode.innerText = likes + 1;
}
activeUpvote(momentName);
};
xhr.onerror = function () {
Expand Down
6 changes: 4 additions & 2 deletions templates/moments.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@
likedMomentNames = [...likedMomentNames, momentName];
localStorage.setItem(likes_localstorage_key, JSON.stringify(likedMomentNames));
const likesNode = document.querySelector('span[data-moment-name="' + momentName + '"]');
const likes = parseInt(likesNode.innerText);
likesNode.innerText = likes + 1;
if (likesNode) {
const likes = parseInt(likesNode.innerText);
likesNode.innerText = likes + 1;
}
activeUpvote(momentName);
};
xhr.onerror = function () {
Expand Down
6 changes: 4 additions & 2 deletions templates/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ <h1 class="posttitle" itemprop="name headline">
likedPostNames = [...likedPostNames, postName];
localStorage.setItem(likes_localstorage_key, JSON.stringify(likedPostNames));
const likesNode = document.querySelector('span[data-post-name="' + postName + '"]');
const likes = parseInt(likesNode.innerText);
likesNode.innerText = likes + 1;
if (likesNode) {
const likes = parseInt(likesNode.innerText);
likesNode.innerText = likes + 1;
}
activeUpvote(postName);
};
xhr.onerror = function () {
Expand Down

0 comments on commit 8e67f32

Please sign in to comment.