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

Exclude flair #53

Open
woj-tek opened this issue Feb 19, 2023 · 3 comments
Open

Exclude flair #53

woj-tek opened this issue Feb 19, 2023 · 3 comments

Comments

@woj-tek
Copy link

woj-tek commented Feb 19, 2023

It would be awesome to be able to see all entries except certain flairs.

@trashhalo
Copy link
Owner

Do you know a sub that uses a lot of flares I can use to test this feature?

@woj-tek
Copy link
Author

woj-tek commented Feb 20, 2023

Not sure if it qualifies as "a lot" but https://old.reddit.com/r/polska/ uses them (and AFAIR requires)

@drixtol
Copy link

drixtol commented May 3, 2023

I for the life of me couldn't get it to work with multiple values, but this seemed to work for blocking a single flair. @trashhalo maybe this could work?

var flair string
flairStr, hasFlair := r.URL.Query()["flair"]
if hasFlair {
	flair = flairStr[0]
}

var blockflair string
blockflairStr, hasblockflair := r.URL.Query()["blockflair"]
if hasblockflair {
	blockflair = blockflairStr[0]
}

loader := articleLoader(client, getArticle)
var thunks []dataloader.Thunk
for _, link := range result.Data.Children {
	if hasSafe && safe && (link.Data.Over18 || strings.ToLower(link.Data.LinkFlairText) == "nsfw") {
		continue
	}

	if scoreLimit && limit > link.Data.Score {
		continue
	}

	if hasFlair && flair != "" && link.Data.LinkFlairText != flair {
		continue
	}

	if hasblockflair && blockflair != "" && link.Data.LinkFlairText == blockflair {
		continue
	}

	thunks = append(thunks, loader.Load(ctx, dataKey(link.Data)))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants