From b660af3a4ae2c828bec395ab003b125b97402488 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 4 Oct 2024 14:15:44 -0500 Subject: [PATCH] Do no filter search if using from filter --- src/state/queries/search-posts.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/state/queries/search-posts.ts b/src/state/queries/search-posts.ts index b3bc721063..8a8a3fa52f 100644 --- a/src/state/queries/search-posts.ts +++ b/src/state/queries/search-posts.ts @@ -41,9 +41,10 @@ export function useSearchPostsQuery({ const moderationOpts = useModerationOpts() const selectArgs = React.useMemo( () => ({ + isSearchingSpecificUser: /from:(\w+)/.test(query), moderationOpts, }), - [moderationOpts], + [query, moderationOpts], ) const lastRun = React.useRef<{ data: InfiniteData @@ -73,7 +74,16 @@ export function useSearchPostsQuery({ enabled: enabled ?? !!moderationOpts, select: React.useCallback( (data: InfiniteData) => { - const {moderationOpts} = selectArgs + const {moderationOpts, isSearchingSpecificUser} = selectArgs + + /* + * If a user applies the `from:` filter, don't apply any + * moderation. Note that if we add any more filtering logic below, we + * may need to adjust this. + */ + if (isSearchingSpecificUser) { + return data + } // Keep track of the last run and whether we can reuse // some already selected pages from there.