Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filteReddit): do not filter own posts #3545

Merged
merged 2 commits into from
Oct 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/modules/filteReddit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ module.options = {
noconfig: process.env.BUILD_TARGET === 'safari' || process.env.BUILD_TARGET === 'edge',
description: 'Show a \'filter visited links\' tab at the top of each subreddit, to easily toggle whether to filter visited posts.',
},
excludeOwnPosts: {
type: 'boolean',
value: true,
description: 'Don\'t filter your own posts',
},
excludeCommentsPage: {
type: 'boolean',
value: true,
Expand Down Expand Up @@ -822,6 +827,16 @@ function scanEntries(ele) {
things.forEach(thing => {
let postSubreddit, currSub;
if (thing.isPost() && !onSavedPage) {
// Do not apply any other filters if posts belong to me
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this above const postTitle, so the function can quit as early as possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

if (module.options.excludeOwnPosts.value) {
const postAuthor = thing.getAuthor().toLowerCase();
// No standard marker for my own posts so compare against the logged in user
const myName = loggedInUser();
if (myName && (myName.toLowerCase() === postAuthor)) {
return;
}
}

const postTitle = thing.getTitle();
const postDomain = thing.getPostDomain();
const postFlair = thing.getPostFlairText();
Expand Down