feat(search): drop quota wording when the live search source is scrape

The search response now reports its source; in scrape mode (zero quota) the
results banner and Load-more button drop the 'uses quota' wording. Adds the
search_source toggle's labels/hints and updates the per-user-limit hint to note
the cost only applies to the api source. EN/HU/DE.
This commit is contained in:
npeter83 2026-06-29 22:30:03 +02:00
parent 396e09189b
commit 1d6dfaf486
8 changed files with 35 additions and 12 deletions

View file

@ -116,9 +116,10 @@ export default function Feed({
placeholderData: keepPreviousData,
});
// Live YouTube search results. Each page spends 100 quota units, so we never auto-paginate
// on scroll — the user pulls more with an explicit button. retry:false so a 429 (quota/limit)
// surfaces at once for inline display. staleTime keeps a revisited search from re-spending.
// Live YouTube search results. We never auto-paginate on scroll — the user pulls more with an
// explicit button (each api-source page spends 100 quota units; scrape-source pages are free).
// retry:false so a 429 (quota/limit) surfaces at once for inline display. staleTime keeps a
// revisited search from re-spending.
const ytQuery = useInfiniteQuery({
queryKey: ["yt-search", ytSearch],
queryFn: ({ pageParam }) => api.searchYoutube(ytSearch as string, pageParam as string | null),
@ -279,6 +280,9 @@ export default function Feed({
: ytQuery.isError
? t("feed.yt.error")
: null;
// The backend reports which source served the search; scrape spends no search quota, so we
// drop the quota warning + "uses quota" wording in that mode.
const zeroQuota = ytQuery.data?.pages?.[0]?.source === "scrape";
return (
<div className="p-4">
@ -303,7 +307,9 @@ export default function Feed({
<span className="text-sm font-semibold truncate">
{t("feed.yt.resultsFor", { query: ytSearch })}
</span>
<span className="text-xs text-muted">{t("feed.yt.quotaNote")}</span>
<span className="text-xs text-muted">
{zeroQuota ? t("feed.yt.freeNote") : t("feed.yt.quotaNote")}
</span>
</div>
{ytQuery.isLoading ? (
@ -333,7 +339,11 @@ export default function Feed({
disabled={ytQuery.isFetchingNextPage}
className="inline-flex items-center gap-2 px-4 py-2 rounded-xl border border-border bg-card text-sm font-medium hover:border-accent hover:text-accent disabled:opacity-50 transition"
>
{ytQuery.isFetchingNextPage ? t("feed.loadingMore") : t("feed.yt.loadMore")}
{ytQuery.isFetchingNextPage
? t("feed.loadingMore")
: zeroQuota
? t("feed.yt.loadMoreFree")
: t("feed.yt.loadMore")}
</button>
</div>
)}