Skip to content

Commit

Permalink
No Recommended: Fix fallback behavior when hiding the entire dash (Ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon authored Aug 23, 2024
1 parent 2767e14 commit 2e37784
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/features/no_recommended/hide_recommended_posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export const styleElement = buildStyle(`
const precedingHiddenPosts = ({ previousElementSibling: previousElement }, count = 0) => {
// If there is no previous sibling, stop counting
if (!previousElement) return count;
// If the previous sibling is not a post, skip over it
if (!previousElement.matches(postSelector) || !previousElement.querySelector(postSelector)) return precedingHiddenPosts(previousElement, count);
// If the previous sibling is hidden, count it and continue
if (previousElement.matches(`[${hiddenAttribute}]`)) return precedingHiddenPosts(previousElement, count + 1);
// If the previous sibling is not a post, skip over it
if (!previousElement.matches(postSelector) || !previousElement.querySelector(postSelector)) return precedingHiddenPosts(previousElement, count);
// Otherwise, we've hit a non-hidden post; stop counting
return count;
};
Expand All @@ -59,7 +59,7 @@ const processPosts = async function (postElements) {
timelineItem.setAttribute(hiddenAttribute, '');

if (precedingHiddenPosts(timelineItem) >= 10) {
timelineItem.setAttribute(hiddenAttribute, '');
timelineItem.setAttribute(unHiddenAttribute, '');
}
});
};
Expand Down

0 comments on commit 2e37784

Please sign in to comment.