Merge branch 'feature/search-in-hash' into 'master'

Include the search query+language as part of the URL hash

See merge request tt-rss/tt-rss!112
This commit is contained in:
Andrew Dolgov 2025-03-31 04:57:52 +00:00
commit 8df250f2eb
2 changed files with 13 additions and 5 deletions

View File

@ -7,7 +7,7 @@ module.exports = {
}, },
"extends": "eslint:recommended", "extends": "eslint:recommended",
"parserOptions": { "parserOptions": {
"ecmaVersion": 2018 "ecmaVersion": 2020
}, },
"rules": { "rules": {
"accessor-pairs": "error", "accessor-pairs": "error",

View File

@ -23,7 +23,7 @@ const Feeds = {
infscroll_disabled: 0, infscroll_disabled: 0,
_infscroll_timeout: false, _infscroll_timeout: false,
_filter_query: false, // TODO: figure out the UI for this _filter_query: false, // TODO: figure out the UI for this
_search_query: false, _search_query: null,
last_search_query: [], last_search_query: [],
_viewfeed_wait_timeout: false, _viewfeed_wait_timeout: false,
_feeds_holder_observer: new IntersectionObserver( _feeds_holder_observer: new IntersectionObserver(
@ -159,7 +159,7 @@ const Feeds = {
this.reload(); this.reload();
}, },
cancelSearch: function() { cancelSearch: function() {
this._search_query = ""; this._search_query = null;
this.reloadCurrent(); this.reloadCurrent();
}, },
// null = get all data, [] would give empty response for specific type // null = get all data, [] would give empty response for specific type
@ -270,6 +270,9 @@ const Feeds = {
console.log('got hash', hash); console.log('got hash', hash);
if (hash.query)
this._search_query = {query: hash.query, search_language: hash.search_language};
if (hash.f != undefined) { if (hash.f != undefined) {
this.open({feed: parseInt(hash.f), is_cat: parseInt(hash.c)}); this.open({feed: parseInt(hash.f), is_cat: parseInt(hash.c)});
} else { } else {
@ -329,7 +332,12 @@ const Feeds = {
console.log('setActive', id, is_cat); console.log('setActive', id, is_cat);
window.requestIdleCallback(() => { 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; this._active_feed_id = id;
@ -664,7 +672,7 @@ const Feeds = {
// disallow empty queries // disallow empty queries
if (!Feeds._search_query.query) if (!Feeds._search_query.query)
Feeds._search_query = false; Feeds._search_query = null;
this.hide(); this.hide();
Feeds.reloadCurrent(); Feeds.reloadCurrent();