-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCommentFilters.tsx
More file actions
45 lines (39 loc) · 1.24 KB
/
CommentFilters.tsx
File metadata and controls
45 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { type AppBskyFeedDefs } from '@atproto/api';
import { getPostText } from './types';
const MinLikeCountFilter = (
min: number
): ((comment: AppBskyFeedDefs.ThreadViewPost) => boolean) => {
return (comment: AppBskyFeedDefs.ThreadViewPost) => {
return (comment.post.likeCount ?? 0) < min;
};
};
const MinCharacterCountFilter = (
min: number
): ((comment: AppBskyFeedDefs.ThreadViewPost) => boolean) => {
return (comment: AppBskyFeedDefs.ThreadViewPost) => {
return getPostText(comment.post.record).length < min;
};
};
const TextContainsFilter = (
text: string
): ((comment: AppBskyFeedDefs.ThreadViewPost) => boolean) => {
return (comment: AppBskyFeedDefs.ThreadViewPost) => {
return getPostText(comment.post.record).toLowerCase().includes(text.toLowerCase());
};
};
const ExactMatchFilter = (
text: string
): ((comment: AppBskyFeedDefs.ThreadViewPost) => boolean) => {
return (comment: AppBskyFeedDefs.ThreadViewPost) => {
return getPostText(comment.post.record).toLowerCase() === text.toLowerCase();
};
};
export const Filters = {
MinLikeCountFilter,
MinCharacterCountFilter,
TextContainsFilter,
ExactMatchFilter,
NoLikes: MinLikeCountFilter(0),
NoPins: ExactMatchFilter('📌'),
};
export default Filters;