Handling of search filters

- Always display "no results" when a query is present
- Placeholder path for no sources selected (ensures URL retains structure)
- Fixes comment https://github.com/jaedb/Iris/issues/906#issuecomment-1776667496
This commit is contained in:
James Barnsley
2024-01-03 10:51:57 +13:00
parent ad1fe8ac50
commit d8eedcb160
4 changed files with 17 additions and 11 deletions

View File

@ -55,6 +55,7 @@ const Content = () => (
<Route path="settings/*" element={<Settings />} />
<Route path="search" element={<Search />} />
<Route path="search/:type/:providers/:term" element={<Search />} />
<Route path="search/:type/:providers" element={<Search />} />
<Route path="artist/:uri/*" element={<Artist />} />
<Route path="album/:uri/" element={<Album />} />
<Route path="album/:uri/:name" element={<Album />} />

View File

@ -38,8 +38,6 @@ const SearchResults = ({
results = results.slice(0, 6);
}
if (all && !results.length) return null;
return (
<div>
<h4>
@ -60,7 +58,7 @@ const SearchResults = ({
</URILink>
)}
</h4>
{results.length > 0 && (
{results.length > 0 ? (
<section className="grid-wrapper">
{type === 'artists' && <Grid items={results} show_source_icon mini={all} />}
{type === 'albums' && <Grid items={results} show_source_icon mini={all} />}
@ -84,6 +82,10 @@ const SearchResults = ({
</Button>
)}
</section>
) : (
<span style={{ opacity: 0.5 }}>
<I18n key="search.no_results" />
</span>
)}
</div>
);

View File

@ -339,6 +339,7 @@ search:
sort: Sort
source: Sources
placeholder: Search
no_results: No results
all:
title: All
artists:

View File

@ -50,7 +50,7 @@ const Search = () => {
const updateSearchQuery = (term, providers) => {
const encodedTerm = encodeURIComponent(term);
navigate(`/search/${type}/${providers.join(',')}/${encodedTerm || ''}`);
navigate(`/search/${type}/${providers.join(',') || 'none'}/${encodedTerm || ''}`);
}
const onReset = () => navigate('/search');
@ -113,13 +113,15 @@ const Search = () => {
onReset={onReset}
/>
<div className="content-wrapper">
{type != 'all' ? (
<SearchResults type={type} />
) : (
<AllSearchResults />
)}
</div>
{term && (
<div className="content-wrapper">
{type != 'all' ? (
<SearchResults type={type} />
) : (
<AllSearchResults />
)}
</div>
)}
</div>
);
}