fix(plex): explain an empty search when filters are also active
A Plex search that returns nothing while a collection/rating filter is active showed a bare "No matches", hiding that the filters — not the query — were the cause. Show how many filters are narrowing the results and offer a one-click Clear filters inline. Translated in all three languages.
This commit is contained in:
parent
6232a66878
commit
d84edebc09
4 changed files with 29 additions and 2 deletions
|
|
@ -2,7 +2,14 @@ import { lazy, Suspense, useEffect, useLayoutEffect, useRef, useState, type CSSP
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { ArrowLeft, CheckCircle2, Info, ListPlus, Play } from "lucide-react";
|
import { ArrowLeft, CheckCircle2, Info, ListPlus, Play } from "lucide-react";
|
||||||
import { api, type PlexCard, type PlexFilters, type PlexPerson } from "../lib/api";
|
import {
|
||||||
|
api,
|
||||||
|
EMPTY_PLEX_FILTERS,
|
||||||
|
plexFilterCount,
|
||||||
|
type PlexCard,
|
||||||
|
type PlexFilters,
|
||||||
|
type PlexPerson,
|
||||||
|
} from "../lib/api";
|
||||||
import { useDebounced } from "../lib/useDebounced";
|
import { useDebounced } from "../lib/useDebounced";
|
||||||
import { useHistorySubview } from "../lib/history";
|
import { useHistorySubview } from "../lib/history";
|
||||||
import PlexPlaylistAdd, { type PlexAddTarget } from "./PlexPlaylistAdd";
|
import PlexPlaylistAdd, { type PlexAddTarget } from "./PlexPlaylistAdd";
|
||||||
|
|
@ -267,7 +274,21 @@ export default function PlexBrowse({
|
||||||
{browseQ.isLoading ? (
|
{browseQ.isLoading ? (
|
||||||
<p className="text-muted text-sm">{t("plex.loading")}</p>
|
<p className="text-muted text-sm">{t("plex.loading")}</p>
|
||||||
) : items.length === 0 ? (
|
) : items.length === 0 ? (
|
||||||
<p className="text-muted text-sm">{dq ? t("plex.noMatches") : t("plex.empty")}</p>
|
dq && plexFilterCount(filters) > 0 ? (
|
||||||
|
// A search that comes up empty WHILE filters are active is usually the filters, not the
|
||||||
|
// query — say so and offer a one-click escape, instead of a bare "No matches".
|
||||||
|
<div className="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||||
|
<span>{t("plex.noMatchesFiltered", { count: plexFilterCount(filters) })}</span>
|
||||||
|
<button
|
||||||
|
onClick={() => setFilters(EMPTY_PLEX_FILTERS)}
|
||||||
|
className="rounded-full border border-border bg-card px-3 py-1 text-xs font-medium transition hover:border-accent hover:text-accent"
|
||||||
|
>
|
||||||
|
{t("plex.filter.clearAll")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<p className="text-muted text-sm">{dq ? t("plex.noMatches") : t("plex.empty")}</p>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<div className="grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3">
|
<div className="grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3">
|
||||||
{items.map((c) => (
|
{items.map((c) => (
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@
|
||||||
"count": "{{count}} Titel",
|
"count": "{{count}} Titel",
|
||||||
"searchCount": "{{count}} Treffer",
|
"searchCount": "{{count}} Treffer",
|
||||||
"noMatches": "Keine Treffer.",
|
"noMatches": "Keine Treffer.",
|
||||||
|
"noMatchesFiltered_one": "Keine Treffer — ein Filter schränkt die Ergebnisse zusätzlich ein.",
|
||||||
|
"noMatchesFiltered_other": "Keine Treffer — {{count}} Filter schränken die Ergebnisse zusätzlich ein.",
|
||||||
"loading": "Wird geladen…",
|
"loading": "Wird geladen…",
|
||||||
"empty": "Noch nichts hier. Starte eine Plex-Synchronisierung auf der Admin-Konfigurationsseite.",
|
"empty": "Noch nichts hier. Starte eine Plex-Synchronisierung auf der Admin-Konfigurationsseite.",
|
||||||
"loadMore": "Mehr laden",
|
"loadMore": "Mehr laden",
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@
|
||||||
"count": "{{count}} titles",
|
"count": "{{count}} titles",
|
||||||
"searchCount": "{{count}} matches",
|
"searchCount": "{{count}} matches",
|
||||||
"noMatches": "No matches.",
|
"noMatches": "No matches.",
|
||||||
|
"noMatchesFiltered_one": "No matches — a filter is also narrowing the results.",
|
||||||
|
"noMatchesFiltered_other": "No matches — {{count}} filters are also narrowing the results.",
|
||||||
"loading": "Loading…",
|
"loading": "Loading…",
|
||||||
"empty": "Nothing here yet. Run a Plex sync from the admin Config page.",
|
"empty": "Nothing here yet. Run a Plex sync from the admin Config page.",
|
||||||
"loadMore": "Load more",
|
"loadMore": "Load more",
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@
|
||||||
"count": "{{count}} cím",
|
"count": "{{count}} cím",
|
||||||
"searchCount": "{{count}} találat",
|
"searchCount": "{{count}} találat",
|
||||||
"noMatches": "Nincs találat.",
|
"noMatches": "Nincs találat.",
|
||||||
|
"noMatchesFiltered_one": "Nincs találat — egy szűrő is szűkíti az eredményt.",
|
||||||
|
"noMatchesFiltered_other": "Nincs találat — {{count}} szűrő is szűkíti az eredményt.",
|
||||||
"loading": "Betöltés…",
|
"loading": "Betöltés…",
|
||||||
"empty": "Még nincs itt semmi. Futtass egy Plex-szinkront az admin Konfiguráció oldalról.",
|
"empty": "Még nincs itt semmi. Futtass egy Plex-szinkront az admin Konfiguráció oldalról.",
|
||||||
"loadMore": "Több betöltése",
|
"loadMore": "Több betöltése",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue