From ca751c10e18a5ceecacc5dbd46b3afce73e43393 Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 30 Mar 2025 18:05:53 +0000 Subject: [PATCH 1/2] Include the search query+language as part of the URL hash. --- js/Feeds.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/Feeds.js b/js/Feeds.js index cecce04e2..9088b7efc 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -23,7 +23,7 @@ const Feeds = { infscroll_disabled: 0, _infscroll_timeout: false, _filter_query: false, // TODO: figure out the UI for this - _search_query: false, + _search_query: null, last_search_query: [], _viewfeed_wait_timeout: false, _feeds_holder_observer: new IntersectionObserver( @@ -159,7 +159,7 @@ const Feeds = { this.reload(); }, cancelSearch: function() { - this._search_query = ""; + this._search_query = null; this.reloadCurrent(); }, // null = get all data, [] would give empty response for specific type @@ -270,6 +270,9 @@ const Feeds = { console.log('got hash', hash); + if (hash.query) + this._search_query = {query: hash.query, search_language: hash.search_language}; + if (hash.f != undefined) { this.open({feed: parseInt(hash.f), is_cat: parseInt(hash.c)}); } else { @@ -329,7 +332,12 @@ const Feeds = { console.log('setActive', id, is_cat); window.requestIdleCallback(() => { - App.Hash.set({f: id, c: is_cat ? 1 : 0}); + App.Hash.set({ + f: id, + c: is_cat ? 1 : 0, + query: Feeds._search_query?.query, + search_language: Feeds._search_query?.search_language, + }); }); this._active_feed_id = id; @@ -664,7 +672,7 @@ const Feeds = { // disallow empty queries if (!Feeds._search_query.query) - Feeds._search_query = false; + Feeds._search_query = null; this.hide(); Feeds.reloadCurrent(); From fdf9a0819780a5949bf8dbd28218148b6370b72b Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 30 Mar 2025 18:12:55 +0000 Subject: [PATCH 2/2] Bump ESLint ecmaVersion to 2020. It wasn't aware of optional chaining. --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index d2f24d663..53184783a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,7 @@ module.exports = { }, "extends": "eslint:recommended", "parserOptions": { - "ecmaVersion": 2018 + "ecmaVersion": 2020 }, "rules": { "accessor-pairs": "error",