From baf01795a99f4cb9aed5e342c8513ce39734a291 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Sat, 16 May 2020 13:28:55 +0530 Subject: [PATCH] stream_popover: Extract method to show error message in topic edit. --- static/js/stream_popover.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js index 6c75872762..e030432511 100644 --- a/static/js/stream_popover.js +++ b/static/js/stream_popover.js @@ -549,6 +549,11 @@ exports.register_topic_handlers = function () { }); $('body').on('click', '#do_move_topic_button', function (e) { + function show_error_msg(msg) { + $("#topic_stream_edit_form_error .error-msg").text(msg); + $("#topic_stream_edit_form_error").show(); + } + const params = $('#move_topic_form').serializeArray().reduce(function (obj, item) { obj[item.name] = item.value; return obj; @@ -608,8 +613,7 @@ exports.register_topic_handlers = function () { } }, error: function (xhr) { - $("#topic_stream_edit_form_error .error-msg").text(xhr.responseJSON.msg); - $("#topic_stream_edit_form_error").show(); + show_error_msg(xhr.responseJSON.msg); }, }); e.preventDefault();