From 2107914ad6952d6e08c147756b7a3858c38da183 Mon Sep 17 00:00:00 2001 From: Akiva Berger Date: Tue, 27 Jan 2026 13:19:32 +0200 Subject: [PATCH] fix: voices ref search --- reader/views.py | 14 ++++++++++++++ static/js/ReaderApp.jsx | 8 ++++++++ static/js/SearchPage.jsx | 2 +- static/js/sheets/SheetsWithRefPage.jsx | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/reader/views.py b/reader/views.py index 1df63450e2..4a054025f3 100644 --- a/reader/views.py +++ b/reader/views.py @@ -941,6 +941,20 @@ def search(request): Search or Search Results page. """ search_params = get_search_params(request.GET) + if request.active_module == VOICES_MODULE and search_params["query"]: + try: + if Ref.is_ref(search_params["query"]): + tref = Ref(search_params["query"]).normal() + params = request.GET.copy() + if "q" in params: + del params["q"] + query_string = params.urlencode() + target = f"/sheets-with-ref/{urllib.parse.quote(tref)}" + if query_string: + target = f"{target}?{query_string}" + return redirect(target, permanent=False) + except Exception: + pass props={ "initialMenu": "search", diff --git a/static/js/ReaderApp.jsx b/static/js/ReaderApp.jsx index d1cf9d11a4..897d489bae 100644 --- a/static/js/ReaderApp.jsx +++ b/static/js/ReaderApp.jsx @@ -1843,6 +1843,14 @@ toggleSignUpModal(modalContentKind = SignUpModalKind.Default) { } } showSearch(searchQuery) { + if (Sefaria.activeModule === Sefaria.VOICES_MODULE && searchQuery) { + const parsedRef = Sefaria.parseRef(searchQuery); + if (!parsedRef?.error) { + const ref = parsedRef.ref || searchQuery; + window.location = `/sheets-with-ref/${encodeURIComponent(ref)}`; + return; + } + } const hasSearchState = !!this.state.panels && this.state.panels.length && !!this.state.panels[0].searchState; const searchState = hasSearchState ? this.state.panels[0].searchState.update({ filtersValid: false }) : new SearchState({ type: SearchState.moduleToSearchType(Sefaria.activeModule)}); diff --git a/static/js/SearchPage.jsx b/static/js/SearchPage.jsx index d8d257ad57..abaea7fe93 100644 --- a/static/js/SearchPage.jsx +++ b/static/js/SearchPage.jsx @@ -147,4 +147,4 @@ SearchPage.propTypes = { }; -export default SearchPage; \ No newline at end of file +export default SearchPage; diff --git a/static/js/sheets/SheetsWithRefPage.jsx b/static/js/sheets/SheetsWithRefPage.jsx index b44b13c587..c22cacd092 100644 --- a/static/js/sheets/SheetsWithRefPage.jsx +++ b/static/js/sheets/SheetsWithRefPage.jsx @@ -205,4 +205,4 @@ const SheetsWithRefPage = ({srefs, searchState, updateSearchState, updateApplied aiBadgeText={aiBadgeText} /> } -export default SheetsWithRefPage; \ No newline at end of file +export default SheetsWithRefPage;