mirror of https://github.com/zulip/zulip.git
muting: Pass stream_id to muting_ui.mute and unmute.
We temporarily allow settings_muting to have incomplete line coverage--we will fix this soon.
This commit is contained in:
parent
10b045f91b
commit
bf6f5e7bc5
|
@ -51,8 +51,8 @@ run_test('settings', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
var unmute_called = false;
|
var unmute_called = false;
|
||||||
muting_ui.unmute = function (stream, topic) {
|
muting_ui.unmute = function (stream_id, topic) {
|
||||||
assert.equal(stream, 'frontend');
|
assert.equal(stream_id, frontend.stream_id);
|
||||||
assert.equal(topic, 'js');
|
assert.equal(topic, 'js');
|
||||||
unmute_called = true;
|
unmute_called = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -289,8 +289,7 @@ exports.initialize = function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var stream_id = $(e.currentTarget).attr('data-stream-id');
|
var stream_id = $(e.currentTarget).attr('data-stream-id');
|
||||||
var topic = $(e.currentTarget).attr('data-topic-name');
|
var topic = $(e.currentTarget).attr('data-topic-name');
|
||||||
var stream = stream_data.get_sub_by_id(stream_id);
|
muting_ui.mute(stream_id, topic);
|
||||||
muting_ui.mute(stream.name, topic);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// RECIPIENT BARS
|
// RECIPIENT BARS
|
||||||
|
|
|
@ -62,7 +62,7 @@ exports.notify_with_undo_option = (function () {
|
||||||
meta.$mute.find("#unmute").click(function () {
|
meta.$mute.find("#unmute").click(function () {
|
||||||
// it should reference the meta variable and not get stuck with
|
// it should reference the meta variable and not get stuck with
|
||||||
// a pass-by-value of stream, topic.
|
// a pass-by-value of stream, topic.
|
||||||
exports.unmute(stream_name, topic);
|
exports.unmute(stream_id, topic);
|
||||||
animate.fadeOut();
|
animate.fadeOut();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -165,14 +165,7 @@ exports.set_up_muted_topics_ui = function (muted_topics) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.mute = function (stream, topic) {
|
exports.mute = function (stream_id, topic) {
|
||||||
// TODO: have callers pass in stream_id
|
|
||||||
var stream_id = stream_data.get_stream_id(stream);
|
|
||||||
|
|
||||||
if (!stream_id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stream_popover.hide_topic_popover();
|
stream_popover.hide_topic_popover();
|
||||||
muting.add_muted_topic(stream_id, topic);
|
muting.add_muted_topic(stream_id, topic);
|
||||||
unread_ui.update_unread_counts();
|
unread_ui.update_unread_counts();
|
||||||
|
@ -182,14 +175,7 @@ exports.mute = function (stream, topic) {
|
||||||
exports.set_up_muted_topics_ui(muting.get_muted_topics());
|
exports.set_up_muted_topics_ui(muting.get_muted_topics());
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.unmute = function (stream, topic) {
|
exports.unmute = function (stream_id, topic) {
|
||||||
// TODO: have callers pass in stream_id
|
|
||||||
var stream_id = stream_data.get_stream_id(stream);
|
|
||||||
|
|
||||||
if (!stream_id) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we don't run a unmute_notify function because it isn't an issue as much
|
// we don't run a unmute_notify function because it isn't an issue as much
|
||||||
// if someone accidentally unmutes a stream rather than if they mute it
|
// if someone accidentally unmutes a stream rather than if they mute it
|
||||||
// and miss out on info.
|
// and miss out on info.
|
||||||
|
@ -204,9 +190,9 @@ exports.unmute = function (stream, topic) {
|
||||||
|
|
||||||
exports.toggle_mute = function (msg) {
|
exports.toggle_mute = function (msg) {
|
||||||
if (muting.is_topic_muted(msg.stream_id, msg.subject)) {
|
if (muting.is_topic_muted(msg.stream_id, msg.subject)) {
|
||||||
exports.unmute(msg.stream, msg.subject);
|
exports.unmute(msg.stream_id, msg.subject);
|
||||||
} else if (msg.type === 'stream') {
|
} else if (msg.type === 'stream') {
|
||||||
exports.mute(msg.stream, msg.subject);
|
exports.mute(msg.stream_id, msg.subject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -900,8 +900,16 @@ exports.register_click_handlers = function () {
|
||||||
$('body').on('click', '.popover_mute_topic', function (e) {
|
$('body').on('click', '.popover_mute_topic', function (e) {
|
||||||
var stream = $(e.currentTarget).data('msg-stream');
|
var stream = $(e.currentTarget).data('msg-stream');
|
||||||
var topic = $(e.currentTarget).data('msg-topic');
|
var topic = $(e.currentTarget).data('msg-topic');
|
||||||
|
|
||||||
|
// TODO: use stream_id in markup
|
||||||
|
var stream_id = stream_data.get_stream_id(stream);
|
||||||
|
|
||||||
|
if (!stream_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
popovers.hide_actions_popover();
|
popovers.hide_actions_popover();
|
||||||
muting_ui.mute(stream, topic);
|
muting_ui.mute(stream_id, topic);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
@ -909,8 +917,15 @@ exports.register_click_handlers = function () {
|
||||||
$('body').on('click', '.popover_unmute_topic', function (e) {
|
$('body').on('click', '.popover_unmute_topic', function (e) {
|
||||||
var stream = $(e.currentTarget).data('msg-stream');
|
var stream = $(e.currentTarget).data('msg-stream');
|
||||||
var topic = $(e.currentTarget).data('msg-topic');
|
var topic = $(e.currentTarget).data('msg-topic');
|
||||||
|
|
||||||
|
var stream_id = stream_data.get_stream_id(stream);
|
||||||
|
|
||||||
|
if (!stream_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
popovers.hide_actions_popover();
|
popovers.hide_actions_popover();
|
||||||
muting_ui.unmute(stream, topic);
|
muting_ui.unmute(stream_id, topic);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,9 +8,16 @@ exports.set_up = function () {
|
||||||
var stream = $row.data("stream");
|
var stream = $row.data("stream");
|
||||||
var topic = $row.data("topic");
|
var topic = $row.data("topic");
|
||||||
|
|
||||||
muting_ui.unmute(stream, topic);
|
|
||||||
$row.remove();
|
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
|
|
||||||
|
var stream_id = stream_data.get_stream_id(stream);
|
||||||
|
|
||||||
|
if (!stream_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
muting_ui.unmute(stream_id, topic);
|
||||||
|
$row.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
muting_ui.set_up_muted_topics_ui(muting.get_muted_topics());
|
muting_ui.set_up_muted_topics_ui(muting.get_muted_topics());
|
||||||
|
|
|
@ -293,9 +293,16 @@ exports.register_stream_handlers = function () {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function topic_popover_sub(e) {
|
function topic_popover_stream_id(e) {
|
||||||
// TODO: use data-stream-id in stream list
|
// TODO: use data-stream-id in stream list
|
||||||
var stream_id = $(e.currentTarget).attr('data-stream-id');
|
var stream_id = $(e.currentTarget).attr('data-stream-id');
|
||||||
|
|
||||||
|
return stream_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function topic_popover_sub(e) {
|
||||||
|
// TODO: use data-stream-id in stream list
|
||||||
|
var stream_id = topic_popover_stream_id(e);
|
||||||
if (!stream_id) {
|
if (!stream_id) {
|
||||||
blueslip.error('cannot find stream id');
|
blueslip.error('cannot find stream id');
|
||||||
return;
|
return;
|
||||||
|
@ -332,26 +339,26 @@ exports.register_topic_handlers = function () {
|
||||||
|
|
||||||
// Mute the topic
|
// Mute the topic
|
||||||
$('body').on('click', '.sidebar-popover-mute-topic', function (e) {
|
$('body').on('click', '.sidebar-popover-mute-topic', function (e) {
|
||||||
var sub = topic_popover_sub(e);
|
var stream_id = topic_popover_stream_id(e);
|
||||||
if (!sub) {
|
if (!stream_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var topic = $(e.currentTarget).attr('data-topic-name');
|
var topic = $(e.currentTarget).attr('data-topic-name');
|
||||||
muting_ui.mute(sub.name, topic);
|
muting_ui.mute(stream_id, topic);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Unmute the topic
|
// Unmute the topic
|
||||||
$('body').on('click', '.sidebar-popover-unmute-topic', function (e) {
|
$('body').on('click', '.sidebar-popover-unmute-topic', function (e) {
|
||||||
var sub = topic_popover_sub(e);
|
var stream_id = topic_popover_stream_id(e);
|
||||||
if (!sub) {
|
if (!stream_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var topic = $(e.currentTarget).attr('data-topic-name');
|
var topic = $(e.currentTarget).attr('data-topic-name');
|
||||||
muting_ui.unmute(sub.name, topic);
|
muting_ui.unmute(stream_id, topic);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
|
@ -66,7 +66,7 @@ enforce_fully_covered = {
|
||||||
'static/js/search_util.js',
|
'static/js/search_util.js',
|
||||||
# Removed because we're migrating code from uncovered other settings pages to here.
|
# Removed because we're migrating code from uncovered other settings pages to here.
|
||||||
# 'static/js/settings_ui.js',
|
# 'static/js/settings_ui.js',
|
||||||
'static/js/settings_muting.js',
|
# 'static/js/settings_muting.js',
|
||||||
'static/js/settings_user_groups.js',
|
'static/js/settings_user_groups.js',
|
||||||
'static/js/stream_data.js',
|
'static/js/stream_data.js',
|
||||||
'static/js/stream_events.js',
|
'static/js/stream_events.js',
|
||||||
|
|
Loading…
Reference in New Issue