feat: browse creator-filtered results without a query

Selecting a creator with an empty query now lists their pages (or
attachments in attachment mode) newest-first, with the same space and
page permission filtering as typed search.
This commit is contained in:
Philipinho
2026-08-25 00:11:04 +01:00
parent 01b36db348
commit 1dae88c899
4 changed files with 24 additions and 16 deletions
@@ -106,7 +106,8 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
}
}, [aiSearchError, t]);
const isLabelBrowse = (filters.labelIds?.length ?? 0) > 0;
const isFilterBrowse =
(filters.labelIds?.length ?? 0) > 0 || !!filters.creatorId;
// while the debounce is pending the empty list is not a settled "no results"
const isQuerySettled = query === debouncedSearchQuery;
@@ -231,11 +232,11 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
</>
) : (
<>
{query.length === 0 && !isLabelBrowse && resultItems.length === 0 && (
{query.length === 0 && !isFilterBrowse && resultItems.length === 0 && (
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
)}
{(query.length > 0 || isLabelBrowse) &&
{(query.length > 0 || isFilterBrowse) &&
!isFetching &&
isQuerySettled &&
resultItems.length === 0 && (
@@ -244,7 +245,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
{resultItems.length > 0 && <>{resultItems}</>}
{(query.length > 0 || isLabelBrowse) && isFetching && (
{(query.length > 0 || isFilterBrowse) && isFetching && (
<Spotlight.Empty>
<Text size="sm" style={{ marginTop: 10 }}>
{t("Searching...")}
@@ -39,11 +39,16 @@ export function useUnifiedSearch(
return await searchPage(backendParams);
}
},
enabled: (!!params.query || (params.labelIds?.length ?? 0) > 0) && enabled,
enabled:
(!!params.query ||
(params.labelIds?.length ?? 0) > 0 ||
!!params.creatorId) &&
enabled,
// keep previous results only within the same search type; page results
// rendered as attachments (or vice versa) crash on missing fields
placeholderData: (previousData, previousQuery) => {
if (!params.query && !params.labelIds?.length) return undefined;
if (!params.query && !params.labelIds?.length && !params.creatorId)
return undefined;
if (previousQuery && previousQuery.queryKey[1] !== searchType) {
return undefined;
}