From 5b4eb8d7b9f5f00ace949d8f008ab61540ceef8b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 10 Dec 2019 09:10:45 +0300 Subject: [PATCH] remove unnecessary "== 1" when checking for init params unsubscribeFeed: check for undefined title correctly --- js/CommonDialogs.js | 2 +- js/Feeds.js | 16 ++++++++-------- js/Headlines.js | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index e0338a97c..c6d476de0 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -385,7 +385,7 @@ define(["dojo/_base/declare"], function (declare) { const msg = __("Unsubscribe from %s?").replace("%s", title); - if (title == undefined || confirm(msg)) { + if (typeof title == "undefined" || confirm(msg)) { Notify.progress("Removing feed..."); const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id}; diff --git a/js/Feeds.js b/js/Feeds.js index 07ec89452..13b952d9a 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -93,7 +93,7 @@ define(["dojo/_base/declare"], function (declare) { } } - this.hideOrShowFeeds(App.getInitParam("hide_read_feeds") == 1); + this.hideOrShowFeeds(App.getInitParam("hide_read_feeds")); this._counters_prev = elems; PluginHost.run(PluginHost.HOOK_COUNTERS_PROCESSED); @@ -147,7 +147,7 @@ define(["dojo/_base/declare"], function (declare) { const treeModel = new fox.FeedStoreModel({ store: store, query: { - "type": App.getInitParam('enable_feed_cats') == 1 ? "category" : "feed" + "type": App.getInitParam('enable_feed_cats') ? "category" : "feed" }, rootId: "root", rootLabel: "Feeds", @@ -212,7 +212,7 @@ define(["dojo/_base/declare"], function (declare) { this.open({feed: -3}); } - this.hideOrShowFeeds(App.getInitParam("hide_read_feeds") == 1); + this.hideOrShowFeeds(App.getInitParam("hide_read_feeds")); if (App.getInitParam("is_default_pw")) { console.warn("user password is at default value"); @@ -237,7 +237,7 @@ define(["dojo/_base/declare"], function (declare) { } // bw_limit disables timeout() so we request initial counters separately - if (App.getInitParam("bw_limit") == "1") { + if (App.getInitParam("bw_limit")) { this.requestCounters(true); } else { setTimeout(() => { @@ -274,7 +274,7 @@ define(["dojo/_base/declare"], function (declare) { if (tree) return tree.selectFeed(feed, is_cat); }, toggleUnread: function() { - const hide = !(App.getInitParam("hide_read_feeds") == "1"); + const hide = !App.getInitParam("hide_read_feeds"); xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => { this.hideOrShowFeeds(hide); @@ -385,7 +385,7 @@ define(["dojo/_base/declare"], function (declare) { } }, catchupFeed: function(feed, is_cat, mode) { - if (is_cat == undefined) is_cat = false; + is_cat = is_cat || false; let str = false; @@ -409,7 +409,7 @@ define(["dojo/_base/declare"], function (declare) { str = str.replace("%s", fn) .replace("%w", mark_what); - if (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { return; } @@ -424,7 +424,7 @@ define(["dojo/_base/declare"], function (declare) { xhrPost("backend.php", catchup_query, (transport) => { App.handleRpcJson(transport); - const show_next_feed = App.getInitParam("on_catchup_show_next_feed") == "1"; + const show_next_feed = App.getInitParam("on_catchup_show_next_feed"); if (show_next_feed) { const nuf = this.getNextUnread(feed, is_cat); diff --git a/js/Headlines.js b/js/Headlines.js index 99f911838..acc4b18e3 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -303,7 +303,7 @@ define(["dojo/_base/declare"], function (declare) { } } - if (App.getInitParam("cdm_auto_catchup") == 1) { + if (App.getInitParam("cdm_auto_catchup")) { let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]"); @@ -919,7 +919,7 @@ define(["dojo/_base/declare"], function (declare) { const row = $("RROW-" + id); if (row) { - if (cmode == undefined) cmode = 2; + if (typeof cmode == "undefined") cmode = 2; switch (cmode) { case 0: @@ -990,7 +990,7 @@ define(["dojo/_base/declare"], function (declare) { str = str.replace("%d", rows.length); str = str.replace("%s", fn); - if (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { return; } @@ -1136,7 +1136,7 @@ define(["dojo/_base/declare"], function (declare) { str = str.replace("%d", rows.length); str = str.replace("%s", fn); - if (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { return; } @@ -1162,7 +1162,7 @@ define(["dojo/_base/declare"], function (declare) { str = str.replace("%d", rows.length); str = str.replace("%s", fn); - if (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { return; }