In-memory search results cache

- Switching between type and provider now negates need for repeat queries
- Mopidy caching varies, so for some providers this has a huge performance gain (eg YouTube)
- Spotify will requery anyway, but the browser handles query caching
This commit is contained in:
James Barnsley
2023-10-10 20:33:51 +13:00
parent bec0cf95e3
commit 8dfd585a3f
5 changed files with 27 additions and 21 deletions

View File

@ -603,8 +603,7 @@ const upgradeSpotifyPlaylistUri = function (uri) {
return upgradeSpotifyPlaylistUris([uri])[0];
};
const getSearchResultKey = ({ provider, type, term }) =>
[provider.replace(':', ''), type, term].join(':');
const getSearchResultKey = ({ provider, type, term }) => [provider, type, term].join(':');
export {
debounce,

View File

@ -7,11 +7,13 @@ const useSearchQuery = () => {
type = 'all',
providers: rawProviders = 'all',
} = useParams();
const allProviders = useSelector((state) => state.mopidy?.uri_schemes || []);
const allProviders = useSelector(
({ mopidy: { uri_schemes } }) => uri_schemes || []
).map((str) => str.replace(/:/g,''));
const providers = rawProviders == 'all'
? [...allProviders]
: rawProviders.split(',').filter((str) => allProviders.indexOf(str) > -1);
const providersString = providers.join(',').replace(/:/g,'');
const providersString = providers.join(',');
return {
term,