Skip to content

Commit

Permalink
Merge pull request #1 from mmktomato/use-getElementsByClassName
Browse files Browse the repository at this point in the history
Thank you!
  • Loading branch information
tsuyoshizawa authored Jan 18, 2021
2 parents e7f7853 + 89573a7 commit 2a1b5c0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ module.exports = (Franz) => {
const likesActivitiesIndex = 3;

const hasUnreads = (sidebarItems, index) => {
return Number($(sidebarItems.get(index)).hasClass(className));
if (!sidebarItems || sidebarItems.length < 1) {
return 0;
}
const sidebarItem = sidebarItems[index];
return Number(sidebarItem.classList.contains(className));
};

const getUnreads = () => {
const sidebarItems = $(".sidebar__item");
const sidebarItems = document.getElementsByClassName("sidebar__item");
const indirectMessages = hasUnreads(sidebarItems, topicsIndex) + hasUnreads(sidebarItems, likesActivitiesIndex);
const directMessages = hasUnreads(sidebarItems, dmIndex) + hasUnreads(sidebarItems, notificationsIndex);

Expand Down

0 comments on commit 2a1b5c0

Please sign in to comment.