From a4376efd0fed4c7e11c5e3b2f60f281331b709e4 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 4 Mar 2017 09:40:46 -0800 Subject: [PATCH] refactor: De-dup code using subs.sub_or_unsub(). --- static/js/subs.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/static/js/subs.js b/static/js/subs.js index 3be2adba66..9403598260 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -1299,12 +1299,7 @@ $(function () { return; } var sub = stream_data.get_sub(stream_name); - - if (sub.subscribed) { - ajaxUnsubscribe(stream_name); - } else { - ajaxSubscribe(stream_name); - } + exports.sub_or_unsub(sub); }); $('.empty_feed_sub_unsub').click(function (e) { @@ -1316,12 +1311,8 @@ $(function () { return; } var sub = stream_data.get_sub(stream_name); + exports.sub_or_unsub(sub); - if (sub.subscribed) { - ajaxUnsubscribe(stream_name); - } else { - ajaxSubscribe(stream_name); - } $('.empty_feed_notice').hide(); $('#empty_narrow_message').show(); });