summaryrefslogtreecommitdiff
path: root/js/Feeds.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-06 22:41:46 +0300
committerAndrew Dolgov <[email protected]>2021-03-06 22:41:46 +0300
commit1d9fa2a42e2cad9ea76ad22edf8919942c853be1 (patch)
tree19f82a883aebd76871d94c81692a26f8aad3d73a /js/Feeds.js
parent7b0b5b55c7a7e0f5e5f63083a5131ea85109bbec (diff)
reduce overhead in hash set/get
Diffstat (limited to 'js/Feeds.js')
-rw-r--r--js/Feeds.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/js/Feeds.js b/js/Feeds.js
index 5a2dee5cf..ad2edf8d5 100644
--- a/js/Feeds.js
+++ b/js/Feeds.js
@@ -236,12 +236,12 @@ const Feeds = {
//document.onkeypress = (event) => { return App.hotkeyHandler(event) };
window.onresize = () => { Headlines.scrollHandler(); }
- /* global hash_get */
- const hash_feed_id = hash_get('f');
- const hash_feed_is_cat = hash_get('c') == "1";
+ const hash = App.Hash.get();
- if (hash_feed_id != undefined) {
- this.open({feed: hash_feed_id, is_cat: hash_feed_is_cat});
+ console.log('got hash', hash);
+
+ if (hash.f != undefined) {
+ this.open({feed: parseInt(hash.f), is_cat: parseInt(hash.c)});
} else {
this.openDefaultFeed();
}
@@ -305,9 +305,12 @@ const Feeds = {
setActive: function(id, is_cat) {
console.log('setActive', id, is_cat);
- /* global hash_set */
- hash_set('f', id);
- hash_set('c', is_cat ? 1 : 0);
+ if ('requestIdleCallback' in window)
+ window.requestIdleCallback(() => {
+ App.Hash.set({f: id, c: is_cat ? 1 : 0});
+ });
+ else
+ App.Hash.set({f: id, c: is_cat ? 1 : 0});
this._active_feed_id = id;
this._active_feed_is_cat = is_cat;