mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
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:
committed by
Tim Abbott
parent
f73600c82c
commit
40f550038d
@@ -130,14 +130,14 @@ var denmark = {
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
stream_id: 1,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
};
|
||||
var social = {
|
||||
subscribed: true,
|
||||
color: 'red',
|
||||
name: 'social',
|
||||
stream_id: 2,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
invite_only: true,
|
||||
};
|
||||
var edgecase_stream = {
|
||||
@@ -145,7 +145,7 @@ var edgecase_stream = {
|
||||
color: 'green',
|
||||
name: 'Bobby <h1>Tables</h1>',
|
||||
stream_id: 3,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
};
|
||||
stream_data.add_sub('Denmark', denmark);
|
||||
stream_data.add_sub('social', social);
|
||||
|
||||
@@ -55,7 +55,7 @@ var denmark = {
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
stream_id: 1,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
};
|
||||
stream_data.add_sub('Denmark', denmark);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ var general = {
|
||||
subscribed: true,
|
||||
name: 'general',
|
||||
stream_id: 10,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
};
|
||||
|
||||
// Muted streams
|
||||
@@ -34,7 +34,7 @@ var muted = {
|
||||
subscribed: true,
|
||||
name: 'muted',
|
||||
stream_id: 20,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
};
|
||||
|
||||
stream_data.add_sub('general', general);
|
||||
|
||||
@@ -31,14 +31,14 @@ run_test('basics', () => {
|
||||
color: 'blue',
|
||||
name: 'Denmark',
|
||||
stream_id: 1,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
};
|
||||
var social = {
|
||||
subscribed: true,
|
||||
color: 'red',
|
||||
name: 'social',
|
||||
stream_id: 2,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
invite_only: true,
|
||||
is_announcement_only: true,
|
||||
};
|
||||
@@ -47,7 +47,7 @@ run_test('basics', () => {
|
||||
color: 'yellow',
|
||||
name: 'test',
|
||||
stream_id: 3,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
invite_only: false,
|
||||
};
|
||||
stream_data.add_sub('Denmark', denmark);
|
||||
@@ -328,7 +328,7 @@ run_test('admin_options', () => {
|
||||
color: 'blue',
|
||||
name: 'stream_to_admin',
|
||||
stream_id: 1,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
invite_only: false,
|
||||
};
|
||||
stream_data.add_sub(sub.name, sub);
|
||||
@@ -583,19 +583,19 @@ run_test('notifications', () => {
|
||||
assert(!stream_data.receives_audible_notifications('India'));
|
||||
});
|
||||
|
||||
run_test('in_home_view', () => {
|
||||
run_test('is_muted', () => {
|
||||
var tony = {
|
||||
stream_id: 999,
|
||||
name: 'tony',
|
||||
subscribed: true,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
};
|
||||
|
||||
var jazy = {
|
||||
stream_id: 500,
|
||||
name: 'jazy',
|
||||
subscribed: false,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
};
|
||||
|
||||
stream_data.add_sub('tony', tony);
|
||||
@@ -618,7 +618,7 @@ run_test('remove_default_stream', () => {
|
||||
stream_id: 674,
|
||||
name: 'remove_me',
|
||||
subscribed: false,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
};
|
||||
|
||||
stream_data.add_sub('remove_me', remove_me);
|
||||
|
||||
@@ -27,7 +27,7 @@ var frontend = {
|
||||
color: 'yellow',
|
||||
name: 'frontend',
|
||||
stream_id: 1,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
invite_only: false,
|
||||
};
|
||||
|
||||
@@ -364,7 +364,7 @@ var dev_help = {
|
||||
color: 'blue',
|
||||
name: 'dev help',
|
||||
stream_id: 2,
|
||||
in_home_view: false,
|
||||
is_muted: true,
|
||||
invite_only: false,
|
||||
};
|
||||
stream_data.add_sub(dev_help.name, dev_help);
|
||||
|
||||
@@ -639,7 +639,7 @@ run_test('rename_stream', () => {
|
||||
name: 'Development',
|
||||
id: 1000,
|
||||
uri: '#narrow/stream/1000-Development',
|
||||
not_in_home_view: false,
|
||||
is_muted: false,
|
||||
invite_only: undefined,
|
||||
is_web_public: undefined,
|
||||
color: payload.color,
|
||||
|
||||
@@ -1207,7 +1207,7 @@ run_test('stream_sidebar_actions', () => {
|
||||
stream: {
|
||||
color: 'red',
|
||||
name: 'devel',
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
id: 55,
|
||||
},
|
||||
};
|
||||
@@ -1257,7 +1257,7 @@ run_test('subscription_settings', () => {
|
||||
can_change_stream_permissions: true,
|
||||
email_address: 'xxxxxxxxxxxxxxx@zulip.com',
|
||||
stream_id: 888,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
};
|
||||
|
||||
var html = '';
|
||||
@@ -1314,7 +1314,7 @@ run_test('subscriptions', () => {
|
||||
invite_only: true,
|
||||
email_address: 'xxxxxxxxxxxxxxx@zulip.com',
|
||||
stream_id: 888,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
},
|
||||
{
|
||||
name: 'social',
|
||||
|
||||
@@ -26,7 +26,7 @@ var social = {
|
||||
stream_id: 200,
|
||||
name: 'social',
|
||||
subscribed: true,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
};
|
||||
stream_data.add_sub('social', social);
|
||||
|
||||
|
||||
@@ -330,13 +330,13 @@ exports.update_calculated_fields = function (sub) {
|
||||
|
||||
exports.all_subscribed_streams_are_in_home_view = function () {
|
||||
return _.every(exports.subscribed_subs(), function (sub) {
|
||||
return sub.in_home_view;
|
||||
return !sub.is_muted;
|
||||
});
|
||||
};
|
||||
|
||||
exports.home_view_stream_names = function () {
|
||||
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 sub.name;
|
||||
@@ -357,12 +357,12 @@ exports.get_color = function (stream_name) {
|
||||
|
||||
exports.in_home_view = function (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) {
|
||||
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 () {
|
||||
@@ -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,
|
||||
subscribed: true,
|
||||
newly_subscribed: false,
|
||||
in_home_view: true,
|
||||
is_muted: false,
|
||||
invite_only: false,
|
||||
desktop_notifications: page_params.enable_stream_desktop_notifications,
|
||||
audible_notifications: page_params.enable_stream_sounds,
|
||||
|
||||
@@ -251,7 +251,7 @@ function stream_home_view_clicked(e) {
|
||||
|
||||
subs.toggle_home(sub);
|
||||
|
||||
if (sub.in_home_view) {
|
||||
if (!sub.is_muted) {
|
||||
sub_settings.find(".mute-note").addClass("hide-mute-note");
|
||||
notification_checkboxes.removeClass("muted-sub");
|
||||
notification_checkboxes.find("input[type='checkbox']").prop("disabled", false);
|
||||
|
||||
@@ -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),
|
||||
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,
|
||||
is_web_public: sub.is_web_public,
|
||||
color: stream_data.get_color(name),
|
||||
|
||||
@@ -5,7 +5,7 @@ var exports = {};
|
||||
exports.update_in_home_view = function (sub, value) {
|
||||
// value is true if we are in home view
|
||||
// TODO: flip the semantics to be is_muting
|
||||
sub.in_home_view = value;
|
||||
sub.is_muted = !value;
|
||||
|
||||
setTimeout(function () {
|
||||
var msg_offset;
|
||||
@@ -48,7 +48,7 @@ exports.update_in_home_view = function (sub, value) {
|
||||
}
|
||||
}, 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");
|
||||
not_in_home_view_checkbox.prop('checked', !value);
|
||||
|
||||
@@ -96,8 +96,8 @@ exports.active_stream = function () {
|
||||
};
|
||||
|
||||
exports.toggle_home = function (sub) {
|
||||
stream_muting.update_in_home_view(sub, !sub.in_home_view);
|
||||
stream_edit.set_stream_property(sub, 'in_home_view', sub.in_home_view);
|
||||
stream_muting.update_in_home_view(sub, sub.is_muted);
|
||||
stream_edit.set_stream_property(sub, 'is_muted', sub.is_muted);
|
||||
};
|
||||
|
||||
exports.toggle_pin_to_top_stream = function (sub) {
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
</li>
|
||||
<li>
|
||||
<a class="toggle_home">
|
||||
{{#if stream.in_home_view}}
|
||||
<i class="fa fa-eye-slash" aria-hidden="true"></i>
|
||||
{{#tr this}}Mute the stream <b>__stream.name__</b>{{/tr}}
|
||||
{{else}}
|
||||
{{#if stream.is_muted}}
|
||||
<i class="fa fa-eye" aria-hidden="true"></i>
|
||||
{{#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}}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{! 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}}">
|
||||
<div class="bottom_left_row">
|
||||
<div class="subscription_block selectable_sidebar_block">
|
||||
|
||||
@@ -50,36 +50,36 @@
|
||||
<ul class="grey-box">
|
||||
<li>
|
||||
<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>
|
||||
<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>
|
||||
</li>
|
||||
<li>
|
||||
<div id="sub_desktop_notifications_setting"
|
||||
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}">
|
||||
<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}}/>
|
||||
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}} {{#if is_muted}}disabled="disabled"{{/if}}/>
|
||||
<label class="subscription-control-label">{{t "Visual desktop notifications" }}</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div id="sub_audible_notifications_setting"
|
||||
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}">
|
||||
<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}}/>
|
||||
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}} {{#if is_muted}}disabled="disabled"{{/if}}/>
|
||||
<label class="subscription-control-label">{{t "Audible desktop notifications" }}</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div id="sub_push_notifications_setting"
|
||||
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}">
|
||||
<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}}/>
|
||||
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}} {{#if is_muted}}disabled="disabled"{{/if}}/>
|
||||
<label class="subscription-control-label">{{t "Mobile notifications" }}</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div id="sub_email_notifications_setting"
|
||||
class="sub_setting_checkbox sub_notification_setting {{#unless in_home_view}}muted-sub{{/unless}}">
|
||||
<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}}/>
|
||||
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}} {{#if is_muted}}disabled="disabled"{{/if}}/>
|
||||
<label class="subscription-control-label">{{t "Email notifications" }}</label>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user