From cdd2229665147358408d6b7321b577a7ced185d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Nystr=C3=B6m?= <35500074+antonnyst@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:16:16 +0100 Subject: [PATCH] Add 'as loaded' sort ordering --- src/js/components/SearchResults.js | 12 +++++++----- src/js/views/Search.js | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/components/SearchResults.js b/src/js/components/SearchResults.js index 91ba997de..633a9bbcc 100755 --- a/src/js/components/SearchResults.js +++ b/src/js/components/SearchResults.js @@ -27,11 +27,13 @@ const SearchResults = ({ const encodedTerm = encodeURIComponent(term); let results = [...rawResults]; - results = sortItems( - results, - (type === 'tracks' && sortField === 'followers' ? 'popularity' : sortField), - sortReverse, - ); + if (sortField) { + results = sortItems( + results, + (type === 'tracks' && sortField === 'followers' ? 'popularity' : sortField), + sortReverse, + ); + } const resultsCount = results.length; if (all && type !== 'tracks' && results.length > 5) { diff --git a/src/js/views/Search.js b/src/js/views/Search.js index 50757b0a2..c4d9be82c 100755 --- a/src/js/views/Search.js +++ b/src/js/views/Search.js @@ -70,6 +70,7 @@ const Search = () => { } const sortOptions = [ + { value: null, label: i18n('fields.filters.as_loaded')}, { value: 'name', label: i18n('common.name') }, { value: 'uri', label: i18n('fields.filters.source') }, { value: 'followers', label: i18n('common.popularity') },