From 9e9927d1d084741622b056d72957a6e02df5df5a Mon Sep 17 00:00:00 2001 From: Brock Whittaker Date: Mon, 2 Oct 2017 15:15:42 -0700 Subject: [PATCH] streams: Refactor `setup_subscriptions_stream_hash` arguments. This refactors the arguments in the `setup_subscriptions_stream_hash` method to remove the `stream_id` param and just take it from the `sub` argument it is passed (which is an object that contains the property, `stream_id`. --- static/js/stream_edit.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index 995044c627..c82ddce3bf 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -2,11 +2,11 @@ var stream_edit = (function () { var exports = {}; -function setup_subscriptions_stream_hash(sub, stream_id) { +function setup_subscriptions_stream_hash(sub) { + var id = sub.stream_id; subs.change_state.prevent_once(); - window.location.hash = "#streams" + "/" + - stream_id + "/" + - hash_util.encodeHashComponent(sub.name); + + window.location.hash = "#streams" + "/" + id + "/" + hash_util.encodeHashComponent(sub.name); } function settings_for_sub(sub) { @@ -568,7 +568,6 @@ $(function () { $("#subscriptions_table").on("click", ".sub_unsub_button", function (e) { var sub = get_sub_for_target(e.target); var stream_row = $(this).parent(); - var stream_id = stream_row.attr("data-stream-id"); subs.sub_or_unsub(sub); var sub_settings = settings_for_sub(sub); var regular_sub_settings = sub_settings.find(".regular_subscription_settings"); @@ -579,7 +578,7 @@ $(function () { regular_sub_settings.removeClass("in"); } - setup_subscriptions_stream_hash(sub, stream_id); + setup_subscriptions_stream_hash(sub); e.preventDefault(); e.stopPropagation(); }); @@ -589,7 +588,7 @@ $(function () { exports.show_stream_row(this, true); var stream_id = $(this).attr("data-stream-id"); var sub = stream_data.get_sub_by_id(stream_id); - setup_subscriptions_stream_hash(sub, stream_id); + setup_subscriptions_stream_hash(sub); } });