subs: Replace all in_home_view uses with is_muted property.

Replace all uses of `in_home_view` subscription property
with `is_muted` property in frontend.

Fixes #12322
This commit is contained in:
Yashashvi Dave
2019-05-15 12:24:25 +05:30
committed by Tim Abbott
parent f73600c82c
commit 40f550038d
16 changed files with 47 additions and 47 deletions

View File

@@ -130,14 +130,14 @@ var denmark = {
color: 'blue', color: 'blue',
name: 'Denmark', name: 'Denmark',
stream_id: 1, stream_id: 1,
in_home_view: false, is_muted: true,
}; };
var social = { var social = {
subscribed: true, subscribed: true,
color: 'red', color: 'red',
name: 'social', name: 'social',
stream_id: 2, stream_id: 2,
in_home_view: true, is_muted: false,
invite_only: true, invite_only: true,
}; };
var edgecase_stream = { var edgecase_stream = {
@@ -145,7 +145,7 @@ var edgecase_stream = {
color: 'green', color: 'green',
name: 'Bobby <h1>Tables</h1>', name: 'Bobby <h1>Tables</h1>',
stream_id: 3, stream_id: 3,
in_home_view: true, is_muted: false,
}; };
stream_data.add_sub('Denmark', denmark); stream_data.add_sub('Denmark', denmark);
stream_data.add_sub('social', social); stream_data.add_sub('social', social);

View File

@@ -55,7 +55,7 @@ var denmark = {
color: 'blue', color: 'blue',
name: 'Denmark', name: 'Denmark',
stream_id: 1, stream_id: 1,
in_home_view: false, is_muted: true,
}; };
stream_data.add_sub('Denmark', denmark); stream_data.add_sub('Denmark', denmark);

View File

@@ -26,7 +26,7 @@ var general = {
subscribed: true, subscribed: true,
name: 'general', name: 'general',
stream_id: 10, stream_id: 10,
in_home_view: true, is_muted: false,
}; };
// Muted streams // Muted streams
@@ -34,7 +34,7 @@ var muted = {
subscribed: true, subscribed: true,
name: 'muted', name: 'muted',
stream_id: 20, stream_id: 20,
in_home_view: false, is_muted: true,
}; };
stream_data.add_sub('general', general); stream_data.add_sub('general', general);

View File

@@ -31,14 +31,14 @@ run_test('basics', () => {
color: 'blue', color: 'blue',
name: 'Denmark', name: 'Denmark',
stream_id: 1, stream_id: 1,
in_home_view: false, is_muted: true,
}; };
var social = { var social = {
subscribed: true, subscribed: true,
color: 'red', color: 'red',
name: 'social', name: 'social',
stream_id: 2, stream_id: 2,
in_home_view: true, is_muted: false,
invite_only: true, invite_only: true,
is_announcement_only: true, is_announcement_only: true,
}; };
@@ -47,7 +47,7 @@ run_test('basics', () => {
color: 'yellow', color: 'yellow',
name: 'test', name: 'test',
stream_id: 3, stream_id: 3,
in_home_view: false, is_muted: true,
invite_only: false, invite_only: false,
}; };
stream_data.add_sub('Denmark', denmark); stream_data.add_sub('Denmark', denmark);
@@ -328,7 +328,7 @@ run_test('admin_options', () => {
color: 'blue', color: 'blue',
name: 'stream_to_admin', name: 'stream_to_admin',
stream_id: 1, stream_id: 1,
in_home_view: false, is_muted: true,
invite_only: false, invite_only: false,
}; };
stream_data.add_sub(sub.name, sub); stream_data.add_sub(sub.name, sub);
@@ -583,19 +583,19 @@ run_test('notifications', () => {
assert(!stream_data.receives_audible_notifications('India')); assert(!stream_data.receives_audible_notifications('India'));
}); });
run_test('in_home_view', () => { run_test('is_muted', () => {
var tony = { var tony = {
stream_id: 999, stream_id: 999,
name: 'tony', name: 'tony',
subscribed: true, subscribed: true,
in_home_view: true, is_muted: false,
}; };
var jazy = { var jazy = {
stream_id: 500, stream_id: 500,
name: 'jazy', name: 'jazy',
subscribed: false, subscribed: false,
in_home_view: false, is_muted: true,
}; };
stream_data.add_sub('tony', tony); stream_data.add_sub('tony', tony);
@@ -618,7 +618,7 @@ run_test('remove_default_stream', () => {
stream_id: 674, stream_id: 674,
name: 'remove_me', name: 'remove_me',
subscribed: false, subscribed: false,
in_home_view: false, is_muted: true,
}; };
stream_data.add_sub('remove_me', remove_me); stream_data.add_sub('remove_me', remove_me);

View File

@@ -27,7 +27,7 @@ var frontend = {
color: 'yellow', color: 'yellow',
name: 'frontend', name: 'frontend',
stream_id: 1, stream_id: 1,
in_home_view: false, is_muted: true,
invite_only: false, invite_only: false,
}; };
@@ -364,7 +364,7 @@ var dev_help = {
color: 'blue', color: 'blue',
name: 'dev help', name: 'dev help',
stream_id: 2, stream_id: 2,
in_home_view: false, is_muted: true,
invite_only: false, invite_only: false,
}; };
stream_data.add_sub(dev_help.name, dev_help); stream_data.add_sub(dev_help.name, dev_help);

View File

@@ -639,7 +639,7 @@ run_test('rename_stream', () => {
name: 'Development', name: 'Development',
id: 1000, id: 1000,
uri: '#narrow/stream/1000-Development', uri: '#narrow/stream/1000-Development',
not_in_home_view: false, is_muted: false,
invite_only: undefined, invite_only: undefined,
is_web_public: undefined, is_web_public: undefined,
color: payload.color, color: payload.color,

View File

@@ -1207,7 +1207,7 @@ run_test('stream_sidebar_actions', () => {
stream: { stream: {
color: 'red', color: 'red',
name: 'devel', name: 'devel',
in_home_view: true, is_muted: false,
id: 55, id: 55,
}, },
}; };
@@ -1257,7 +1257,7 @@ run_test('subscription_settings', () => {
can_change_stream_permissions: true, can_change_stream_permissions: true,
email_address: 'xxxxxxxxxxxxxxx@zulip.com', email_address: 'xxxxxxxxxxxxxxx@zulip.com',
stream_id: 888, stream_id: 888,
in_home_view: true, is_muted: false,
}; };
var html = ''; var html = '';
@@ -1314,7 +1314,7 @@ run_test('subscriptions', () => {
invite_only: true, invite_only: true,
email_address: 'xxxxxxxxxxxxxxx@zulip.com', email_address: 'xxxxxxxxxxxxxxx@zulip.com',
stream_id: 888, stream_id: 888,
in_home_view: true, is_muted: false,
}, },
{ {
name: 'social', name: 'social',

View File

@@ -26,7 +26,7 @@ var social = {
stream_id: 200, stream_id: 200,
name: 'social', name: 'social',
subscribed: true, subscribed: true,
in_home_view: true, is_muted: false,
}; };
stream_data.add_sub('social', social); stream_data.add_sub('social', social);

View File

@@ -330,13 +330,13 @@ exports.update_calculated_fields = function (sub) {
exports.all_subscribed_streams_are_in_home_view = function () { exports.all_subscribed_streams_are_in_home_view = function () {
return _.every(exports.subscribed_subs(), function (sub) { return _.every(exports.subscribed_subs(), function (sub) {
return sub.in_home_view; return !sub.is_muted;
}); });
}; };
exports.home_view_stream_names = function () { exports.home_view_stream_names = function () {
var home_view_subs = _.filter(exports.subscribed_subs(), function (sub) { var home_view_subs = _.filter(exports.subscribed_subs(), function (sub) {
return sub.in_home_view; return !sub.is_muted;
}); });
return _.map(home_view_subs, function (sub) { return _.map(home_view_subs, function (sub) {
return sub.name; return sub.name;
@@ -357,12 +357,12 @@ exports.get_color = function (stream_name) {
exports.in_home_view = function (stream_id) { exports.in_home_view = function (stream_id) {
var sub = exports.get_sub_by_id(stream_id); var sub = exports.get_sub_by_id(stream_id);
return sub !== undefined && sub.in_home_view; return sub !== undefined && !sub.is_muted;
}; };
exports.name_in_home_view = function (stream_name) { exports.name_in_home_view = function (stream_name) {
var sub = exports.get_sub(stream_name); var sub = exports.get_sub(stream_name);
return sub !== undefined && sub.in_home_view; return sub !== undefined && !sub.is_muted;
}; };
exports.notifications_in_home_view = function () { exports.notifications_in_home_view = function () {
@@ -581,7 +581,7 @@ exports.create_sub_from_server_data = function (stream_name, attrs) {
render_subscribers: !page_params.realm_is_zephyr_mirror_realm || attrs.invite_only === true, render_subscribers: !page_params.realm_is_zephyr_mirror_realm || attrs.invite_only === true,
subscribed: true, subscribed: true,
newly_subscribed: false, newly_subscribed: false,
in_home_view: true, is_muted: false,
invite_only: false, invite_only: false,
desktop_notifications: page_params.enable_stream_desktop_notifications, desktop_notifications: page_params.enable_stream_desktop_notifications,
audible_notifications: page_params.enable_stream_sounds, audible_notifications: page_params.enable_stream_sounds,

View File

@@ -251,7 +251,7 @@ function stream_home_view_clicked(e) {
subs.toggle_home(sub); subs.toggle_home(sub);
if (sub.in_home_view) { if (!sub.is_muted) {
sub_settings.find(".mute-note").addClass("hide-mute-note"); sub_settings.find(".mute-note").addClass("hide-mute-note");
notification_checkboxes.removeClass("muted-sub"); notification_checkboxes.removeClass("muted-sub");
notification_checkboxes.find("input[type='checkbox']").prop("disabled", false); notification_checkboxes.find("input[type='checkbox']").prop("disabled", false);

View File

@@ -215,7 +215,7 @@ function build_stream_sidebar_li(sub) {
name: name, name: name,
id: sub.stream_id, id: sub.stream_id,
uri: hash_util.by_stream_uri(sub.stream_id), uri: hash_util.by_stream_uri(sub.stream_id),
not_in_home_view: stream_data.in_home_view(sub.stream_id) === false, is_muted: stream_data.in_home_view(sub.stream_id) === false,
invite_only: sub.invite_only, invite_only: sub.invite_only,
is_web_public: sub.is_web_public, is_web_public: sub.is_web_public,
color: stream_data.get_color(name), color: stream_data.get_color(name),

View File

@@ -5,7 +5,7 @@ var exports = {};
exports.update_in_home_view = function (sub, value) { exports.update_in_home_view = function (sub, value) {
// value is true if we are in home view // value is true if we are in home view
// TODO: flip the semantics to be is_muting // TODO: flip the semantics to be is_muting
sub.in_home_view = value; sub.is_muted = !value;
setTimeout(function () { setTimeout(function () {
var msg_offset; var msg_offset;
@@ -48,7 +48,7 @@ exports.update_in_home_view = function (sub, value) {
} }
}, 0); }, 0);
stream_list.set_in_home_view(sub.stream_id, sub.in_home_view); stream_list.set_in_home_view(sub.stream_id, !sub.is_muted);
var not_in_home_view_checkbox = $(".subscription_settings[data-stream-id='" + sub.stream_id + "'] #sub_setting_not_in_home_view .sub_setting_control"); var not_in_home_view_checkbox = $(".subscription_settings[data-stream-id='" + sub.stream_id + "'] #sub_setting_not_in_home_view .sub_setting_control");
not_in_home_view_checkbox.prop('checked', !value); not_in_home_view_checkbox.prop('checked', !value);

View File

@@ -96,8 +96,8 @@ exports.active_stream = function () {
}; };
exports.toggle_home = function (sub) { exports.toggle_home = function (sub) {
stream_muting.update_in_home_view(sub, !sub.in_home_view); stream_muting.update_in_home_view(sub, sub.is_muted);
stream_edit.set_stream_property(sub, 'in_home_view', sub.in_home_view); stream_edit.set_stream_property(sub, 'is_muted', sub.is_muted);
}; };
exports.toggle_pin_to_top_stream = function (sub) { exports.toggle_pin_to_top_stream = function (sub) {

View File

@@ -24,12 +24,12 @@
</li> </li>
<li> <li>
<a class="toggle_home"> <a class="toggle_home">
{{#if stream.in_home_view}} {{#if stream.is_muted}}
<i class="fa fa-eye-slash" aria-hidden="true"></i>
{{#tr this}}Mute the stream <b>__stream.name__</b>{{/tr}}
{{else}}
<i class="fa fa-eye" aria-hidden="true"></i> <i class="fa fa-eye" aria-hidden="true"></i>
{{#tr this}}Unmute the stream <b>__stream.name__</b>{{/tr}} {{#tr this}}Unmute the stream <b>__stream.name__</b>{{/tr}}
{{else}}
<i class="fa fa-eye-slash" aria-hidden="true"></i>
{{#tr this}}Mute the stream <b>__stream.name__</b>{{/tr}}
{{/if}} {{/if}}
</a> </a>
</li> </li>

View File

@@ -1,6 +1,6 @@
{{! Stream sidebar rows }} {{! Stream sidebar rows }}
<li class="narrow-filter{{#if not_in_home_view}} out_of_home_view{{/if}}" <li class="narrow-filter{{#if is_muted}} out_of_home_view{{/if}}"
data-stream-id="{{id}}" data-stream-name="{{name}}"> data-stream-id="{{id}}" data-stream-name="{{name}}">
<div class="bottom_left_row"> <div class="bottom_left_row">
<div class="subscription_block selectable_sidebar_block"> <div class="subscription_block selectable_sidebar_block">

View File

@@ -50,36 +50,36 @@
<ul class="grey-box"> <ul class="grey-box">
<li> <li>
<div id="sub_setting_not_in_home_view" class="sub_setting_checkbox sub-mute-setting"> <div id="sub_setting_not_in_home_view" class="sub_setting_checkbox sub-mute-setting">
<input id="mutestream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#unless in_home_view}}checked{{/unless}} /> <input id="mutestream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if is_muted}}checked{{/if}} />
<label class="subscription-control-label">{{t "Mute stream" }}</label> <label class="subscription-control-label">{{t "Mute stream" }}</label>
<p class="mute-note {{#if in_home_view}}hide-mute-note{{/if}}">{{t "Muted streams don't show up in \"All messages\" or generate notifications unless you are mentioned." }}</p> <p class="mute-note {{#unless is_muted}}hide-mute-note{{/unless}}">{{t "Muted streams don't show up in \"All messages\" or generate notifications unless you are mentioned." }}</p>
</div> </div>
</li> </li>
<li> <li>
<div id="sub_desktop_notifications_setting" <div id="sub_desktop_notifications_setting"
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}"> class="sub_setting_checkbox sub_notification_setting {{#if is_muted}}muted-sub{{/if}}">
<input id="desktop-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if desktop_notifications_display}}checked{{/if}} {{#unless in_home_view}}disabled="disabled"{{/unless}}/> <input id="desktop-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if desktop_notifications_display}}checked{{/if}} {{#if is_muted}}disabled="disabled"{{/if}}/>
<label class="subscription-control-label">{{t "Visual desktop notifications" }}</label> <label class="subscription-control-label">{{t "Visual desktop notifications" }}</label>
</div> </div>
</li> </li>
<li> <li>
<div id="sub_audible_notifications_setting" <div id="sub_audible_notifications_setting"
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}"> class="sub_setting_checkbox sub_notification_setting {{#if is_muted}}muted-sub{{/if}}">
<input id="audible-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if audible_notifications_display}}checked{{/if}} {{#unless in_home_view}}disabled="disabled"{{/unless}}/> <input id="audible-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if audible_notifications_display}}checked{{/if}} {{#if is_muted}}disabled="disabled"{{/if}}/>
<label class="subscription-control-label">{{t "Audible desktop notifications" }}</label> <label class="subscription-control-label">{{t "Audible desktop notifications" }}</label>
</div> </div>
</li> </li>
<li> <li>
<div id="sub_push_notifications_setting" <div id="sub_push_notifications_setting"
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}"> class="sub_setting_checkbox sub_notification_setting {{#if is_muted}}muted-sub{{/if}}">
<input id="push-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if push_notifications_display}}checked{{/if}} {{#unless in_home_view}}disabled="disabled"{{/unless}}/> <input id="push-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if push_notifications_display}}checked{{/if}} {{#if is_muted}}disabled="disabled"{{/if}}/>
<label class="subscription-control-label">{{t "Mobile notifications" }}</label> <label class="subscription-control-label">{{t "Mobile notifications" }}</label>
</div> </div>
</li> </li>
<li> <li>
<div id="sub_email_notifications_setting" <div id="sub_email_notifications_setting"
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}"> class="sub_setting_checkbox sub_notification_setting {{#if is_muted}}muted-sub{{/if}}">
<input id="email-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if email_notifications_display}}checked{{/if}} {{#unless in_home_view}}disabled="disabled"{{/unless}}/> <input id="email-notifystream-{{stream_id}}" class="sub_setting_control" type="checkbox" tabindex="-1" {{#if email_notifications_display}}checked{{/if}} {{#if is_muted}}disabled="disabled"{{/if}}/>
<label class="subscription-control-label">{{t "Email notifications" }}</label> <label class="subscription-control-label">{{t "Email notifications" }}</label>
</div> </div>
</li> </li>