From 16967d676160409135e2dd0bb2b76b02b5fa234a Mon Sep 17 00:00:00 2001 From: Balaji2198 Date: Wed, 7 Mar 2018 18:01:23 +0530 Subject: [PATCH] static/js/settings_streams.js: Refactor delete_default_stream method. --- static/js/settings_streams.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/static/js/settings_streams.js b/static/js/settings_streams.js index d8eb7bbe9a..38256f09b0 100644 --- a/static/js/settings_streams.js +++ b/static/js/settings_streams.js @@ -87,6 +87,18 @@ function make_stream_default(stream_name) { }); } +exports.delete_default_stream = function (stream_name, default_stream_row, alert_element) { + channel.del({ + url: "/json/default_streams" + "?" + $.param({ stream_name: stream_name }), + error: function (xhr) { + ui_report.generic_row_button_error(xhr, alert_element); + }, + success: function () { + default_stream_row.remove(); + }, + }); +}; + exports.set_up = function () { meta.loaded = true; @@ -128,16 +140,7 @@ exports.set_up = function () { $("body").on("click", ".default_stream_row .remove-default-stream", function (e) { var row = $(this).closest(".default_stream_row"); var stream_name = row.attr("id"); - - channel.del({ - url: "/json/default_streams" + "?" + $.param({ stream_name: stream_name }), - error: function (xhr) { - ui_report.generic_row_button_error(xhr, $(e.target)); - }, - success: function () { - row.remove(); - }, - }); + exports.delete_default_stream(stream_name, row, $(e.target)); }); };