mirror of https://github.com/zulip/zulip.git
static/js/stream_data: Rename `in_home_view` functions.
This commit is contained in:
parent
40f550038d
commit
784d02bf60
|
@ -79,8 +79,8 @@ run_test('basics', () => {
|
|||
assert.equal(stream_data.get_name('denMARK'), 'Denmark');
|
||||
assert.equal(stream_data.get_name('unknown Stream'), 'unknown Stream');
|
||||
|
||||
assert(stream_data.in_home_view(social.stream_id));
|
||||
assert(!stream_data.in_home_view(denmark.stream_id));
|
||||
assert(!stream_data.is_muted(social.stream_id));
|
||||
assert(stream_data.is_muted(denmark.stream_id));
|
||||
|
||||
assert.equal(stream_data.maybe_get_stream_name(), undefined);
|
||||
assert.equal(stream_data.maybe_get_stream_name(social.stream_id), 'social');
|
||||
|
@ -600,17 +600,17 @@ run_test('is_muted', () => {
|
|||
|
||||
stream_data.add_sub('tony', tony);
|
||||
stream_data.add_sub('jazy', jazy);
|
||||
assert(stream_data.name_in_home_view('tony'));
|
||||
assert(!stream_data.name_in_home_view('jazy'));
|
||||
assert(!stream_data.name_in_home_view('EEXISTS'));
|
||||
assert(!stream_data.is_stream_muted_by_name('tony'));
|
||||
assert(stream_data.is_stream_muted_by_name('jazy'));
|
||||
assert(stream_data.is_stream_muted_by_name('EEXISTS'));
|
||||
});
|
||||
|
||||
run_test('notifications_in_home_view', () => {
|
||||
run_test('is_notifications_stream_muted', () => {
|
||||
page_params.notifications_stream = 'tony';
|
||||
assert(stream_data.notifications_in_home_view());
|
||||
assert(!stream_data.is_notifications_stream_muted());
|
||||
|
||||
page_params.notifications_stream = 'jazy';
|
||||
assert(!stream_data.notifications_in_home_view());
|
||||
assert(stream_data.is_notifications_stream_muted());
|
||||
});
|
||||
|
||||
run_test('remove_default_stream', () => {
|
||||
|
|
|
@ -282,8 +282,8 @@ run_test('topics', () => {
|
|||
return stream_id_dct[stream_name];
|
||||
};
|
||||
|
||||
global.stream_data.name_in_home_view = function (stream_name) {
|
||||
return stream_name !== 'muted';
|
||||
global.stream_data.is_stream_muted_by_name = function (stream_name) {
|
||||
return stream_name === 'muted';
|
||||
};
|
||||
|
||||
global.unread.topic_has_any_unread = function (stream_id) {
|
||||
|
|
|
@ -303,8 +303,8 @@ run_test('home_messages', () => {
|
|||
stream_data.is_subscribed = function () {
|
||||
return true;
|
||||
};
|
||||
stream_data.in_home_view = function () {
|
||||
return true;
|
||||
stream_data.is_muted = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
var stream_id = 401;
|
||||
|
|
|
@ -41,7 +41,8 @@ function message_in_home(message) {
|
|||
return true;
|
||||
}
|
||||
|
||||
return stream_data.in_home_view(message.stream_id);
|
||||
// We don't display muted streams in 'All messages' view
|
||||
return !stream_data.is_muted(message.stream_id);
|
||||
}
|
||||
|
||||
function message_matches_search_term(message, operator, operand) {
|
||||
|
|
|
@ -443,7 +443,7 @@ exports.message_is_notifiable = function (message) {
|
|||
// Messages to muted streams that don't mention us specifically
|
||||
// are not notifiable.
|
||||
if (message.type === "stream" &&
|
||||
!stream_data.in_home_view(message.stream_id)) {
|
||||
stream_data.is_muted(message.stream_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ exports.get_local_notify_mix_reason = function (message) {
|
|||
return i18n.t("Sent! Your message was sent to a topic you have muted.");
|
||||
}
|
||||
|
||||
if (message.type === "stream" && !stream_data.in_home_view(message.stream_id)) {
|
||||
if (message.type === "stream" && stream_data.is_muted(message.stream_id)) {
|
||||
return i18n.t("Sent! Your message was sent to a stream you have muted.");
|
||||
}
|
||||
|
||||
|
|
|
@ -355,19 +355,27 @@ exports.get_color = function (stream_name) {
|
|||
return sub.color;
|
||||
};
|
||||
|
||||
exports.in_home_view = function (stream_id) {
|
||||
exports.is_muted = function (stream_id) {
|
||||
var sub = exports.get_sub_by_id(stream_id);
|
||||
return sub !== undefined && !sub.is_muted;
|
||||
// Return true for undefined streams
|
||||
if (sub === undefined) {
|
||||
return true;
|
||||
}
|
||||
return sub.is_muted;
|
||||
};
|
||||
|
||||
exports.name_in_home_view = function (stream_name) {
|
||||
exports.is_stream_muted_by_name = function (stream_name) {
|
||||
var sub = exports.get_sub(stream_name);
|
||||
return sub !== undefined && !sub.is_muted;
|
||||
// Return true for undefined streams
|
||||
if (sub === undefined) {
|
||||
return true;
|
||||
}
|
||||
return sub.is_muted;
|
||||
};
|
||||
|
||||
exports.notifications_in_home_view = function () {
|
||||
exports.is_notifications_stream_muted = function () {
|
||||
// TODO: add page_params.notifications_stream_id
|
||||
return exports.name_in_home_view(page_params.notifications_stream);
|
||||
return exports.is_stream_muted_by_name(page_params.notifications_stream);
|
||||
};
|
||||
|
||||
exports.is_subscribed = function (stream_name) {
|
||||
|
|
|
@ -215,7 +215,7 @@ function build_stream_sidebar_li(sub) {
|
|||
name: name,
|
||||
id: sub.stream_id,
|
||||
uri: hash_util.by_stream_uri(sub.stream_id),
|
||||
is_muted: stream_data.in_home_view(sub.stream_id) === false,
|
||||
is_muted: stream_data.is_muted(sub.stream_id) === true,
|
||||
invite_only: sub.invite_only,
|
||||
is_web_public: sub.is_web_public,
|
||||
color: stream_data.get_color(name),
|
||||
|
|
|
@ -25,7 +25,7 @@ function make_tab_data() {
|
|||
return true;
|
||||
}
|
||||
|
||||
return !stream_data.in_home_view(stream_id);
|
||||
return stream_data.is_muted(stream_id);
|
||||
}
|
||||
|
||||
function in_all() {
|
||||
|
|
|
@ -198,7 +198,7 @@ exports.get_next_topic = function (curr_stream, curr_topic) {
|
|||
var my_streams = stream_sort.get_streams();
|
||||
|
||||
my_streams = _.filter(my_streams, function (stream_name) {
|
||||
if (stream_data.name_in_home_view(stream_name)) {
|
||||
if (!stream_data.is_stream_muted_by_name(stream_name)) {
|
||||
return true;
|
||||
}
|
||||
if (stream_name === curr_stream) {
|
||||
|
|
|
@ -305,7 +305,7 @@ exports.unread_topic_counter = (function () {
|
|||
}
|
||||
});
|
||||
res.stream_count.set(stream_id, stream_count);
|
||||
if (stream_data.in_home_view(stream_id)) {
|
||||
if (!stream_data.is_muted(stream_id)) {
|
||||
res.stream_unread_messages += stream_count;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue