frontend: Add new user_settings module for user's settings.

We add a new user_settings module similar to page_params
module in frontend and use it to access user's personal
settings instead of page_params.
This commit is contained in:
Sahil Batra 2021-07-28 19:30:58 +05:30 committed by Tim Abbott
parent ea44b6bcc1
commit 998d710275
61 changed files with 305 additions and 298 deletions

View File

@ -7,7 +7,7 @@ const _ = require("lodash");
const {mock_esm, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const timerender = mock_esm("../../static/js/timerender");
@ -551,7 +551,7 @@ test("get_items_for_users", ({override}) => {
people.add_active_user(alice);
people.add_active_user(fred);
user_status.set_away(alice.user_id);
page_params.emojiset = "google";
user_settings.emojiset = "google";
const status_emoji_info = {
emoji_name: "car",
emoji_code: "1f697",

View File

@ -9,7 +9,7 @@ const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const noop = () => {};
@ -308,7 +308,7 @@ test_ui("enter_with_preview_open", ({override}) => {
$("#compose .undo_markdown_preview").show();
$("#compose .preview_message_area").show();
$("#compose .markdown_preview").hide();
page_params.enter_sends = true;
user_settings.enter_sends = true;
let send_message_called = false;
override(compose, "send_message", () => {
send_message_called = true;
@ -320,7 +320,7 @@ test_ui("enter_with_preview_open", ({override}) => {
assert.ok($("#compose .markdown_preview").visible());
assert.ok(send_message_called);
page_params.enter_sends = false;
user_settings.enter_sends = false;
$("#compose-textarea").trigger("blur");
compose.enter_with_preview_open();
assert.ok($("#compose-textarea").is_focused());
@ -329,7 +329,7 @@ test_ui("enter_with_preview_open", ({override}) => {
$("#compose-textarea").val("");
$("#compose .preview_message_area").show();
$("#enter_sends").prop("checked", true);
page_params.enter_sends = true;
user_settings.enter_sends = true;
compose.enter_with_preview_open();

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {mock_esm, set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const noop = () => {};
@ -992,7 +992,7 @@ test("initialize", ({override, mock_template}) => {
compose_textarea_typeahead_called = true;
};
page_params.enter_sends = false;
user_settings.enter_sends = false;
ct.initialize();
@ -1044,7 +1044,7 @@ test("initialize", ({override, mock_template}) => {
event.target.id = "stream_message_recipient_topic";
$("form#send_message_form").trigger(event);
event.target.id = "compose-textarea";
page_params.enter_sends = false;
user_settings.enter_sends = false;
event.metaKey = true;
let compose_finish_called = false;
override(compose, "finish", () => {
@ -1056,7 +1056,7 @@ test("initialize", ({override, mock_template}) => {
event.metaKey = false;
event.ctrlKey = true;
$("form#send_message_form").trigger(event);
page_params.enter_sends = true;
user_settings.enter_sends = true;
event.ctrlKey = false;
event.altKey = true;
$("form#send_message_form").trigger(event);
@ -1102,7 +1102,7 @@ test("initialize", ({override, mock_template}) => {
override(channel, "patch", (params) => {
assert.equal(params.url, "/json/settings");
assert.equal(params.idempotent, true);
assert.deepEqual(params.data, {enter_sends: page_params.enter_sends});
assert.deepEqual(params.data, {enter_sends: user_settings.enter_sends});
channel_patch_called = true;
});
@ -1110,7 +1110,7 @@ test("initialize", ({override, mock_template}) => {
$("#enter_sends").trigger("click");
// Now we re-run both .initialize() and the click handler, this time
// with enter_sends: page_params.enter_sends being true
// with enter_sends: user_settings.enter_sends being true
$("#enter_sends").is = () => true;
$("#enter_sends").trigger("click");

View File

@ -7,7 +7,7 @@ const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const noop = () => {};
@ -649,15 +649,15 @@ run_test("typing", ({override}) => {
run_test("user_settings", ({override}) => {
settings_display.set_default_language_name = () => {};
let event = event_fixtures.user_settings__default_language;
page_params.default_language = "en";
user_settings.default_language = "en";
override(settings_display, "update_page", noop);
dispatch(event);
assert_same(page_params.default_language, "fr");
assert_same(user_settings.default_language, "fr");
event = event_fixtures.user_settings__left_side_userlist;
page_params.left_side_userlist = false;
user_settings.left_side_userlist = false;
dispatch(event);
assert_same(page_params.left_side_userlist, true);
assert_same(user_settings.left_side_userlist, true);
// We alias message_list.narrowed to message_lists.current
// to make sure we get line coverage on re-rendering
@ -674,31 +674,31 @@ run_test("user_settings", ({override}) => {
override(message_lists.home, "rerender", noop);
event = event_fixtures.user_settings__twenty_four_hour_time;
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
dispatch(event);
assert_same(page_params.twenty_four_hour_time, true);
assert_same(user_settings.twenty_four_hour_time, true);
assert_same(called, true);
event = event_fixtures.user_settings__translate_emoticons;
page_params.translate_emoticons = false;
user_settings.translate_emoticons = false;
dispatch(event);
assert_same(page_params.translate_emoticons, true);
assert_same(user_settings.translate_emoticons, true);
event = event_fixtures.user_settings__high_contrast_mode;
page_params.high_contrast_mode = false;
user_settings.high_contrast_mode = false;
let toggled = [];
$("body").toggleClass = (cls) => {
toggled.push(cls);
};
dispatch(event);
assert_same(page_params.high_contrast_mode, true);
assert_same(user_settings.high_contrast_mode, true);
assert_same(toggled, ["high-contrast"]);
event = event_fixtures.user_settings__dense_mode;
page_params.dense_mode = false;
user_settings.dense_mode = false;
toggled = [];
dispatch(event);
assert_same(page_params.dense_mode, true);
assert_same(user_settings.dense_mode, true);
assert_same(toggled, ["less_dense_mode", "more_dense_mode"]);
$("body").fadeOut = (secs) => {
@ -713,45 +713,45 @@ run_test("user_settings", ({override}) => {
{
const stub = make_stub();
event = event_fixtures.user_settings__color_scheme_dark;
page_params.color_scheme = 1;
user_settings.color_scheme = 1;
override(night_mode, "enable", stub.f); // automatically checks if called
dispatch(event);
assert.equal(stub.num_calls, 1);
assert.equal(page_params.color_scheme, 2);
assert.equal(user_settings.color_scheme, 2);
}
{
const stub = make_stub();
event = event_fixtures.user_settings__color_scheme_light;
page_params.color_scheme = 1;
user_settings.color_scheme = 1;
override(night_mode, "disable", stub.f); // automatically checks if called
dispatch(event);
assert.equal(stub.num_calls, 1);
assert.equal(page_params.color_scheme, 3);
assert.equal(user_settings.color_scheme, 3);
}
{
event = event_fixtures.user_settings__default_view_recent_topics;
page_params.default_view = "all_messages";
user_settings.default_view = "all_messages";
dispatch(event);
assert.equal(page_params.default_view, "recent_topics");
assert.equal(user_settings.default_view, "recent_topics");
}
{
event = event_fixtures.user_settings__default_view_all_messages;
page_params.default_view = "recent_topics";
user_settings.default_view = "recent_topics";
dispatch(event);
assert.equal(page_params.default_view, "all_messages");
assert.equal(user_settings.default_view, "all_messages");
}
{
const stub = make_stub();
event = event_fixtures.user_settings__color_scheme_automatic;
page_params.color_scheme = 2;
user_settings.color_scheme = 2;
override(night_mode, "default_preference_checker", stub.f); // automatically checks if called
dispatch(event);
assert.equal(stub.num_calls, 1);
assert.equal(page_params.color_scheme, 1);
assert.equal(user_settings.color_scheme, 1);
}
{
@ -760,42 +760,42 @@ run_test("user_settings", ({override}) => {
called = false;
override(settings_display, "report_emojiset_change", stub.f);
override(activity, "build_user_sidebar", noop);
page_params.emojiset = "text";
user_settings.emojiset = "text";
dispatch(event);
assert.equal(stub.num_calls, 1);
assert_same(called, true);
assert_same(page_params.emojiset, "google");
assert_same(user_settings.emojiset, "google");
}
override(starred_messages, "rerender_ui", noop);
event = event_fixtures.user_settings__starred_message_counts;
page_params.starred_message_counts = false;
user_settings.starred_message_counts = false;
dispatch(event);
assert_same(page_params.starred_message_counts, true);
assert_same(user_settings.starred_message_counts, true);
override(scroll_bar, "set_layout_width", noop);
event = event_fixtures.user_settings__fluid_layout_width;
page_params.fluid_layout_width = false;
user_settings.fluid_layout_width = false;
dispatch(event);
assert_same(page_params.fluid_layout_width, true);
assert_same(user_settings.fluid_layout_width, true);
{
const stub = make_stub();
event = event_fixtures.user_settings__demote_inactive_streams;
override(stream_data, "set_filter_out_inactives", noop);
override(stream_list, "update_streams_sidebar", stub.f);
page_params.demote_inactive_streams = 1;
user_settings.demote_inactive_streams = 1;
dispatch(event);
assert.equal(stub.num_calls, 1);
assert_same(page_params.demote_inactive_streams, 2);
assert_same(user_settings.demote_inactive_streams, 2);
}
override(compose, "toggle_enter_sends_ui", noop);
event = event_fixtures.user_settings__enter_sends;
page_params.enter_sends = false;
user_settings.enter_sends = false;
dispatch(event);
assert_same(page_params.enter_sends, true);
assert_same(user_settings.enter_sends, true);
{
event = event_fixtures.user_settings__enable_stream_audible_notifications;

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {mock_esm, set_global, zrequire, with_overrides} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {user_settings} = require("../zjsunit/zpage_params");
const ls_container = new Map();
const noop = () => {};
@ -33,7 +33,7 @@ mock_esm("../../static/js/stream_data", {
return "#FFFFFF";
},
});
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
const {localstorage} = zrequire("localstorage");
const drafts = zrequire("drafts");

View File

@ -6,7 +6,7 @@ const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {user_settings} = require("../zjsunit/zpage_params");
let window_stub;
set_global("location", {
@ -168,7 +168,7 @@ function test_helper({override, change_tab}) {
run_test("hash_interactions", ({override}) => {
window_stub = $.create("window-stub");
page_params.default_view = "recent_topics";
user_settings.default_view = "recent_topics";
override(recent_topics_util, "is_visible", () => false);
const helper = test_helper({override, change_tab: true});

View File

@ -94,6 +94,8 @@ run_test("tr_tag", ({mock_template}) => {
full_name: "John Doe",
password_auth_enabled: false,
avatar_url: "http://example.com",
},
user_settings: {
left_side_userlist: false,
twenty_four_hour_time: false,
enable_stream_desktop_notifications: false,

View File

@ -7,7 +7,7 @@ const markdown_assert = require("../zjsunit/markdown_assert");
const {set_global, with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
set_global("location", {
origin: "http://zulip.zulipdev.com",
@ -30,7 +30,7 @@ const example_realm_linkifiers = [
id: 3,
},
];
page_params.translate_emoticons = false;
user_settings.translate_emoticons = false;
function Image() {
return {};
@ -254,7 +254,7 @@ test("marked_shared", () => {
}
const message = {raw_content: test.input};
page_params.translate_emoticons = test.translate_emoticons || false;
user_settings.translate_emoticons = test.translate_emoticons || false;
markdown.apply_markdown(message);
const output = message.content;
const error_message = `Failure in test: ${test.name}`;
@ -571,7 +571,7 @@ test("marked", () => {
for (const test_case of test_cases) {
// Disable emoji conversion by default.
page_params.translate_emoticons = test_case.translate_emoticons || false;
user_settings.translate_emoticons = test_case.translate_emoticons || false;
const input = test_case.input;
const expected = test_case.expected;

View File

@ -6,13 +6,13 @@ const _ = require("lodash");
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const {user_settings} = require("../zjsunit/zpage_params");
set_global("document", "document-stub");
const noop = () => {};
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
mock_esm("../../static/js/message_lists", {home: "stub"});
@ -25,7 +25,7 @@ mock_esm("../../static/js/timerender", {
return [{outerHTML: String(time1.getTime()) + " - " + String(time2.getTime())}];
},
stringify_time(time) {
if (page_params.twenty_four_hour_time) {
if (user_settings.twenty_four_hour_time) {
return time.toString("HH:mm");
}
return time.toString("h:mm TT");

View File

@ -4,7 +4,7 @@ const {strict: assert} = require("assert");
const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
// Dependencies
@ -53,10 +53,10 @@ function test(label, f) {
run_test(label, ({override}) => {
page_params.is_admin = false;
page_params.realm_users = [];
page_params.enable_desktop_notifications = true;
page_params.enable_sounds = true;
page_params.wildcard_mentions_notify = true;
page_params.notification_sound = "ding";
user_settings.enable_desktop_notifications = true;
user_settings.enable_sounds = true;
user_settings.wildcard_mentions_notify = true;
user_settings.notification_sound = "ding";
f({override});
});
}
@ -165,7 +165,7 @@ test("message_is_notifiable", () => {
assert.equal(notifications.message_is_notifiable(message), true);
// But not if it's disabled
page_params.wildcard_mentions_notify = false;
user_settings.wildcard_mentions_notify = false;
assert.equal(notifications.should_send_desktop_notification(message), false);
assert.equal(notifications.should_send_audible_notification(message), false);
assert.equal(notifications.message_is_notifiable(message), true);
@ -177,7 +177,7 @@ test("message_is_notifiable", () => {
assert.equal(notifications.message_is_notifiable(message), true);
// Reset state
page_params.wildcard_mentions_notify = true;
user_settings.wildcard_mentions_notify = true;
general.wildcard_mentions_notify = null;
// Case 6: If a message is in a muted stream
@ -251,13 +251,13 @@ test("message_is_notifiable", () => {
stream_id: general.stream_id,
topic: "whatever",
};
page_params.notification_sound = "none";
user_settings.notification_sound = "none";
assert.equal(notifications.should_send_desktop_notification(message), true);
assert.equal(notifications.should_send_audible_notification(message), false);
assert.equal(notifications.message_is_notifiable(message), true);
// Reset state
page_params.notification_sound = "ding";
user_settings.notification_sound = "ding";
// If none of the above cases apply
// (ie: topic is not muted, message does not mention user,

View File

@ -10,7 +10,7 @@ const {$t} = require("../zjsunit/i18n");
const {mock_esm, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const message_user_ids = mock_esm("../../static/js/message_user_ids");
@ -473,17 +473,17 @@ test_people("user_timezone", () => {
format: "H:mm",
};
page_params.twenty_four_hour_time = true;
user_settings.twenty_four_hour_time = true;
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
expected_pref.format = "h:mm a";
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
page_params.twenty_four_hour_time = true;
user_settings.twenty_four_hour_time = true;
assert.equal(people.get_user_time(me.user_id), "0:09");
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
assert.equal(people.get_user_time(me.user_id), "12:09 AM");
});

View File

@ -6,7 +6,7 @@ const {mock_cjs, mock_esm, with_field, zrequire} = require("../zjsunit/namespace
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {user_settings} = require("../zjsunit/zpage_params");
let clipboard_args;
class Clipboard {
@ -18,7 +18,7 @@ class Clipboard {
mock_cjs("clipboard", Clipboard);
const realm_playground = mock_esm("../../static/js/realm_playground");
page_params.emojiset = "apple";
user_settings.emojiset = "apple";
const rm = zrequire("rendered_markdown");
const people = zrequire("people");
@ -300,12 +300,12 @@ run_test("timestamp-twenty-four-hour-time", ({mock_template}) => {
$content.set_find_results("time", $array([$timestamp]));
// We will temporarily change the 24h setting for this test.
with_field(page_params, "twenty_four_hour_time", true, () => {
with_field(user_settings, "twenty_four_hour_time", true, () => {
rm.update_elements($content);
assert.equal($timestamp.html(), '<i class="fa fa-clock-o"></i>\nWed, Jul 15 2020, 20:40\n');
});
with_field(page_params, "twenty_four_hour_time", false, () => {
with_field(user_settings, "twenty_four_hour_time", false, () => {
rm.update_elements($content);
assert.equal(
$timestamp.html(),
@ -342,14 +342,14 @@ run_test("emoji", () => {
called = true;
};
$content.set_find_results(".emoji", $emoji);
page_params.emojiset = "text";
user_settings.emojiset = "text";
rm.update_elements($content);
assert.ok(called);
// Set page parameters back so that test run order is independent
page_params.emojiset = "apple";
user_settings.emojiset = "apple";
});
run_test("spoiler-header", () => {

View File

@ -4,19 +4,19 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const {user_settings} = require("../zjsunit/zpage_params");
const settings_config = zrequire("settings_config");
run_test("all_notifications", () => {
page_params.enable_stream_desktop_notifications = false;
page_params.enable_stream_audible_notifications = true;
page_params.enable_stream_push_notifications = true;
page_params.enable_stream_email_notifications = false;
page_params.enable_desktop_notifications = false;
page_params.enable_sounds = true;
page_params.enable_offline_push_notifications = false;
page_params.enable_offline_email_notifications = true;
user_settings.enable_stream_desktop_notifications = false;
user_settings.enable_stream_audible_notifications = true;
user_settings.enable_stream_push_notifications = true;
user_settings.enable_stream_email_notifications = false;
user_settings.enable_desktop_notifications = false;
user_settings.enable_sounds = true;
user_settings.enable_offline_push_notifications = false;
user_settings.enable_offline_email_notifications = true;
// Check that it throws error if incorrect settings name
// is passed. In this case, we articulate that with
@ -24,7 +24,7 @@ run_test("all_notifications", () => {
// the case, if a wrong setting_name is passed.
assert.throws(settings_config.all_notifications, "Incorrect setting_name passed");
page_params.wildcard_mentions_notify = false;
user_settings.wildcard_mentions_notify = false;
const notifications = settings_config.all_notifications();
assert.deepEqual(notifications.general_settings, [

View File

@ -4,7 +4,7 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const settings_data = zrequire("settings_data");
const settings_config = zrequire("settings_config");
@ -244,10 +244,10 @@ test_message_policy(
);
run_test("using_dark_theme", () => {
page_params.color_scheme = settings_config.color_scheme_values.night.code;
user_settings.color_scheme = settings_config.color_scheme_values.night.code;
assert.equal(settings_data.using_dark_theme(), true);
page_params.color_scheme = settings_config.color_scheme_values.automatic.code;
user_settings.color_scheme = settings_config.color_scheme_values.automatic.code;
window.matchMedia = (query) => {
assert.equal(query, "(prefers-color-scheme: dark)");
@ -261,7 +261,7 @@ run_test("using_dark_theme", () => {
};
assert.equal(settings_data.using_dark_theme(), false);
page_params.color_scheme = settings_config.color_scheme_values.day.code;
user_settings.color_scheme = settings_config.color_scheme_values.day.code;
assert.equal(settings_data.using_dark_theme(), false);
});

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {with_overrides, zrequire} = require("../zjsunit/namespace");
const {make_stub} = require("../zjsunit/stub");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const message_store = zrequire("message_store");
const starred_messages = zrequire("starred_messages");
@ -95,7 +95,7 @@ run_test("rerender_ui", () => {
starred_messages.starred_ids.add(id);
}
page_params.starred_message_counts = true;
user_settings.starred_message_counts = true;
with_overrides((override) => {
const stub = make_stub();
override(stream_popover, "hide_topic_popover", () => {});
@ -106,7 +106,7 @@ run_test("rerender_ui", () => {
assert.equal(args.count, 3);
});
page_params.starred_message_counts = false;
user_settings.starred_message_counts = false;
with_overrides((override) => {
const stub = make_stub();
override(stream_popover, "hide_topic_popover", () => {});

View File

@ -7,7 +7,7 @@ const _ = require("lodash");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const blueslip = require("../zjsunit/zblueslip");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const color_data = zrequire("color_data");
const stream_topic_history = zrequire("stream_topic_history");
@ -215,7 +215,7 @@ test("renames", () => {
test("is_active", () => {
let sub;
page_params.demote_inactive_streams =
user_settings.demote_inactive_streams =
settings_config.demote_inactive_streams_values.automatic.code;
stream_data.set_filter_out_inactives();
@ -246,7 +246,7 @@ test("is_active", () => {
assert.ok(stream_data.is_active(sub));
page_params.demote_inactive_streams =
user_settings.demote_inactive_streams =
settings_config.demote_inactive_streams_values.always.code;
stream_data.set_filter_out_inactives();
@ -274,7 +274,8 @@ test("is_active", () => {
assert.ok(stream_data.is_active(sub));
page_params.demote_inactive_streams = settings_config.demote_inactive_streams_values.never.code;
user_settings.demote_inactive_streams =
settings_config.demote_inactive_streams_values.never.code;
stream_data.set_filter_out_inactives();
sub = {name: "pets", subscribed: false, stream_id: 111};
@ -503,13 +504,13 @@ test("notifications", () => {
assert.ok(!stream_data.receives_notifications(india.stream_id, "desktop_notifications"));
assert.ok(!stream_data.receives_notifications(india.stream_id, "audible_notifications"));
page_params.enable_stream_desktop_notifications = true;
page_params.enable_stream_audible_notifications = true;
user_settings.enable_stream_desktop_notifications = true;
user_settings.enable_stream_audible_notifications = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "desktop_notifications"));
assert.ok(stream_data.receives_notifications(india.stream_id, "audible_notifications"));
page_params.enable_stream_desktop_notifications = false;
page_params.enable_stream_audible_notifications = false;
user_settings.enable_stream_desktop_notifications = false;
user_settings.enable_stream_audible_notifications = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "desktop_notifications"));
assert.ok(!stream_data.receives_notifications(india.stream_id, "audible_notifications"));
@ -520,38 +521,38 @@ test("notifications", () => {
india.desktop_notifications = false;
india.audible_notifications = false;
page_params.enable_stream_desktop_notifications = true;
page_params.enable_stream_audible_notifications = true;
user_settings.enable_stream_desktop_notifications = true;
user_settings.enable_stream_audible_notifications = true;
assert.ok(!stream_data.receives_notifications(india.stream_id, "desktop_notifications"));
assert.ok(!stream_data.receives_notifications(india.stream_id, "audible_notifications"));
page_params.wildcard_mentions_notify = true;
user_settings.wildcard_mentions_notify = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "wildcard_mentions_notify"));
page_params.wildcard_mentions_notify = false;
user_settings.wildcard_mentions_notify = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "wildcard_mentions_notify"));
india.wildcard_mentions_notify = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "wildcard_mentions_notify"));
page_params.wildcard_mentions_notify = true;
user_settings.wildcard_mentions_notify = true;
india.wildcard_mentions_notify = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "wildcard_mentions_notify"));
page_params.enable_stream_push_notifications = true;
user_settings.enable_stream_push_notifications = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "push_notifications"));
page_params.enable_stream_push_notifications = false;
user_settings.enable_stream_push_notifications = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "push_notifications"));
india.push_notifications = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "push_notifications"));
page_params.enable_stream_push_notifications = true;
user_settings.enable_stream_push_notifications = true;
india.push_notifications = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "push_notifications"));
page_params.enable_stream_email_notifications = true;
user_settings.enable_stream_email_notifications = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "email_notifications"));
page_params.enable_stream_email_notifications = false;
user_settings.enable_stream_email_notifications = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "email_notifications"));
india.email_notifications = true;
assert.ok(stream_data.receives_notifications(india.stream_id, "email_notifications"));
page_params.enable_stream_email_notifications = true;
user_settings.enable_stream_email_notifications = true;
india.email_notifications = false;
assert.ok(!stream_data.receives_notifications(india.stream_id, "email_notifications"));
@ -581,11 +582,11 @@ test("notifications", () => {
};
stream_data.add_sub(antarctica);
page_params.enable_stream_desktop_notifications = true;
page_params.enable_stream_audible_notifications = true;
page_params.enable_stream_email_notifications = false;
page_params.enable_stream_push_notifications = false;
page_params.wildcard_mentions_notify = true;
user_settings.enable_stream_desktop_notifications = true;
user_settings.enable_stream_audible_notifications = true;
user_settings.enable_stream_email_notifications = false;
user_settings.enable_stream_push_notifications = false;
user_settings.wildcard_mentions_notify = true;
india.desktop_notifications = null;
india.audible_notifications = true;
@ -770,7 +771,7 @@ test("initialize", () => {
stream_data.initialize(get_params());
}
page_params.demote_inactive_streams = 1;
user_settings.demote_inactive_streams = 1;
page_params.realm_notifications_stream_id = -1;
initialize();
@ -800,7 +801,7 @@ test("initialize", () => {
});
test("filter inactives", () => {
page_params.demote_inactive_streams =
user_settings.demote_inactive_streams =
settings_config.demote_inactive_streams_values.automatic.code;
const params = {};

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {mock_esm, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
const noop = () => {};
@ -295,7 +295,7 @@ test_ui("subscriber_pills", ({override, mock_template}) => {
const {stream_notification_settings, pm_mention_notification_settings} = settings_config;
for (const setting of [...stream_notification_settings, ...pm_mention_notification_settings]) {
page_params[setting] = true;
user_settings[setting] = true;
}
stream_row_handler.call(fake_this, event);

View File

@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
set_global("document", "document-stub");
@ -95,7 +95,7 @@ function test_ui(label, f) {
test_ui("create_sidebar_row", ({override, mock_template}) => {
// Make a couple calls to create_sidebar_row() and make sure they
// generate the right markup as well as play nice with get_stream_li().
page_params.demote_inactive_streams = 1;
user_settings.demote_inactive_streams = 1;
override(unread, "num_unread_for_stream", () => num_unread_for_stream);
stream_data.add_sub(devel);

View File

@ -9,9 +9,9 @@ const {$t} = require("../zjsunit/i18n");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
const {user_settings} = require("../zjsunit/zpage_params");
page_params.twenty_four_hour_time = true;
user_settings.twenty_four_hour_time = true;
const timerender = zrequire("timerender");
@ -179,7 +179,7 @@ run_test("get_timestamp_for_flatpickr", () => {
});
run_test("absolute_time_12_hour", () => {
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
// timestamp with hour > 12, same year
let timestamp = 1555091573000; // 4/12/2019 5:52:53 PM (UTC+0)
@ -209,7 +209,7 @@ run_test("absolute_time_12_hour", () => {
});
run_test("absolute_time_24_hour", () => {
page_params.twenty_four_hour_time = true;
user_settings.twenty_four_hour_time = true;
// timestamp with hour > 12, same year
let timestamp = 1555091573000; // 4/12/2019 5:52:53 PM (UTC+0)
@ -244,11 +244,11 @@ run_test("get_full_datetime", () => {
assert.equal(timerender.get_full_datetime(time), expected);
// test 24 hour time setting.
page_params.twenty_four_hour_time = true;
user_settings.twenty_four_hour_time = true;
expected = "translated: 5/18/2017 at 21:12:53 UTC";
assert.equal(timerender.get_full_datetime(time), expected);
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
// Test the GMT[+-]x:y logic.
const previous_env_tz = process.env.TZ;
@ -316,18 +316,18 @@ run_test("last_seen_status_from_date", () => {
run_test("set_full_datetime", () => {
let time = new Date(1549958107000); // Tuesday 2/12/2019 07:55:07 AM (UTC+0)
page_params.twenty_four_hour_time = true;
user_settings.twenty_four_hour_time = true;
let time_str = timerender.stringify_time(time);
let expected = "07:55";
assert.equal(time_str, expected);
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
time_str = timerender.stringify_time(time);
expected = "7:55 AM";
assert.equal(time_str, expected);
time = new Date(1549979707000); // Tuesday 2/12/2019 13:55:07 PM (UTC+0)
page_params.twenty_four_hour_time = false;
user_settings.twenty_four_hour_time = false;
time_str = timerender.stringify_time(time);
expected = "1:55 PM";
assert.equal(time_str, expected);

View File

@ -6,7 +6,7 @@ const _ = require("lodash");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const {page_params, user_settings} = require("../zjsunit/zpage_params");
page_params.realm_push_notifications_enabled = false;
@ -43,13 +43,13 @@ function assert_zero_counts(counts) {
}
function test_notifiable_count(home_unread_messages, expected_notifiable_count) {
page_params.desktop_icon_count_display = 1;
user_settings.desktop_icon_count_display = 1;
let notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, home_unread_messages);
page_params.desktop_icon_count_display = 2;
user_settings.desktop_icon_count_display = 2;
notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, expected_notifiable_count);
page_params.desktop_icon_count_display = 3;
user_settings.desktop_icon_count_display = 3;
notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, 0);
}

View File

@ -100,6 +100,8 @@ try {
require("../../static/js/i18n");
namespace.mock_esm("../../static/js/page_params", zpage_params);
require("../../static/js/page_params");
namespace.mock_esm("../../static/js/user_settings", zpage_params);
require("../../static/js/user_settings");
run_one_module(file);

View File

@ -1,6 +1,7 @@
"use strict";
exports.page_params = {};
exports.user_settings = {};
exports.reset = () => {
for (const field in exports.page_params) {
@ -8,4 +9,9 @@ exports.reset = () => {
delete exports.page_params[field];
}
}
for (const field in exports.user_settings) {
if (Object.prototype.hasOwnProperty.call(exports.user_settings, field)) {
delete exports.user_settings[field];
}
}
};

View File

@ -33,6 +33,7 @@ import * as sub_store from "./sub_store";
import * as transmit from "./transmit";
import * as ui_report from "./ui_report";
import * as upload from "./upload";
import {user_settings} from "./user_settings";
import * as util from "./util";
import * as zcommand from "./zcommand";
@ -120,7 +121,7 @@ export function empty_topic_placeholder() {
export function toggle_enter_sends_ui() {
const send_button = $("#compose-send-button");
if (page_params.enter_sends) {
if (user_settings.enter_sends) {
send_button.fadeOut();
} else {
send_button.fadeIn();
@ -260,7 +261,7 @@ export function send_message(request = create_message_object()) {
}
export function enter_with_preview_open() {
if (page_params.enter_sends) {
if (user_settings.enter_sends) {
// If enter_sends is enabled, we attempt to send the message
finish();
} else {

View File

@ -17,6 +17,7 @@ import * as people from "./people";
import * as settings_config from "./settings_config";
import * as settings_data from "./settings_data";
import * as stream_data from "./stream_data";
import {user_settings} from "./user_settings";
import * as util from "./util";
let user_acknowledged_all_everyone = false;
@ -650,7 +651,7 @@ export function validate() {
if (/^\s*$/.test(message_content)) {
// Avoid showing an error message when "enter sends" is enabled,
// as it is more likely that the user has hit "Enter" accidentally.
if (!page_params.enter_sends) {
if (!user_settings.enter_sends) {
compose_error.show(
$t_html({defaultMessage: "You have nothing to send!"}),
$("#compose-textarea"),

View File

@ -27,6 +27,7 @@ import * as timerender from "./timerender";
import * as typeahead_helper from "./typeahead_helper";
import * as user_groups from "./user_groups";
import * as user_pill from "./user_pill";
import {user_settings} from "./user_settings";
// **********************************
// AN IMPORTANT NOTE ABOUT TYPEAHEADS
@ -137,7 +138,7 @@ export function should_enter_send(e) {
const has_non_shift_modifier_key = e.ctrlKey || e.metaKey || e.altKey;
const has_modifier_key = e.shiftKey || has_non_shift_modifier_key;
let this_enter_sends;
if (page_params.enter_sends) {
if (user_settings.enter_sends) {
// With the enter_sends setting, we should send
// the message unless the user was holding a
// modifier key.
@ -1092,7 +1093,7 @@ export function initialize() {
$("form#send_message_form").on("keyup", handle_keyup);
$("#enter_sends").on("click", () => {
page_params.enter_sends = $("#enter_sends").is(":checked");
user_settings.enter_sends = $("#enter_sends").is(":checked");
compose.toggle_enter_sends_ui();
// Refocus in the content box so you can continue typing or
@ -1102,11 +1103,11 @@ export function initialize() {
return channel.patch({
url: "/json/settings",
idempotent: true,
data: {enter_sends: page_params.enter_sends},
data: {enter_sends: user_settings.enter_sends},
});
});
$("#enter_sends").prop("checked", page_params.enter_sends);
if (page_params.enter_sends) {
$("#enter_sends").prop("checked", user_settings.enter_sends);
if (user_settings.enter_sends) {
$("#compose-send-button").hide();
}

View File

@ -12,11 +12,11 @@ import * as blueslip from "./blueslip";
import * as compose_ui from "./compose_ui";
import * as message_lists from "./message_lists";
import * as message_store from "./message_store";
import {page_params} from "./page_params";
import * as popovers from "./popovers";
import * as reactions from "./reactions";
import * as rows from "./rows";
import * as ui from "./ui";
import {user_settings} from "./user_settings";
import * as user_status_ui from "./user_status_ui";
// Emoji picker is of fixed width and height. Update these
@ -785,7 +785,10 @@ export function register_click_handlers() {
e.stopPropagation();
hide_emoji_popover();
const emoji_name = $(this).attr("data-emoji-name");
let emoji_info = {emoji_name, emoji_alt_code: page_params.emojiset === "text"};
let emoji_info = {
emoji_name,
emoji_alt_code: user_settings.emojiset === "text",
};
if (!emoji_info.emoji_alt_code) {
emoji_info = {...emoji_info, ...emoji.get_emoji_details_by_name(emoji_name)};
}

View File

@ -4,7 +4,7 @@ import twitter_sheet from "emoji-datasource-twitter/img/twitter/sheets-256/64.pn
import octopus_url from "../generated/emoji/images-google-64/1f419.png";
import {page_params} from "./page_params";
import {user_settings} from "./user_settings";
import google_blob_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/google-blob-sprite.css";
import google_css from "!style-loader?injectType=lazyStyleTag!css-loader!../generated/emoji-styles/google-sprite.css";
@ -41,7 +41,7 @@ export async function select(name) {
}
export function initialize() {
select(page_params.emojiset);
select(user_settings.emojiset);
// Load the octopus image in the background, so that the browser
// will cache it for later use. Note that we hardcode the octopus

View File

@ -24,6 +24,7 @@ import * as settings_toggle from "./settings_toggle";
import * as stream_settings_ui from "./stream_settings_ui";
import * as top_left_corner from "./top_left_corner";
import * as ui_util from "./ui_util";
import {user_settings} from "./user_settings";
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
// or locally: docs/subsystems/hashchange-system.md
@ -105,9 +106,9 @@ function show_default_view() {
//
// We only allow all_messages and recent_topics
// to be rendered without a hash.
if (page_params.default_view === "recent_topics") {
if (user_settings.default_view === "recent_topics") {
recent_topics_ui.show();
} else if (page_params.default_view === "all_messages") {
} else if (user_settings.default_view === "all_messages") {
show_all_message_view();
} else {
// NOTE: Setting a hash which is not rendered on
@ -116,7 +117,7 @@ function show_default_view() {
// go back in browser history. See
// https://chat.zulip.org/#narrow/stream/9-issues/topic/Browser.20back.20button.20on.20RT
// for detailed description of the issue.
window.location.hash = page_params.default_view;
window.location.hash = user_settings.default_view;
}
}

View File

@ -1,8 +1,8 @@
import * as hash_util from "./hash_util";
import {page_params} from "./page_params";
import * as people from "./people";
import * as stream_data from "./stream_data";
import * as user_groups from "./user_groups";
import {user_settings} from "./user_settings";
/*
This config is in a separate file for partly
@ -44,5 +44,5 @@ export const get_helpers = () => ({
stream_topic_hash: hash_util.by_stream_topic_uri,
// settings
should_translate_emoticons: () => page_params.translate_emoticons,
should_translate_emoticons: () => user_settings.translate_emoticons,
});

View File

@ -23,6 +23,7 @@ import * as stream_ui_updates from "./stream_ui_updates";
import * as ui from "./ui";
import * as unread from "./unread";
import * as unread_ops from "./unread_ops";
import {user_settings} from "./user_settings";
const notice_memory = new Map();
@ -91,7 +92,7 @@ export function initialize() {
}
function update_notification_sound_source() {
const notification_sound = page_params.notification_sound;
const notification_sound = user_settings.notification_sound;
const audio_file_without_extension = "/static/audio/notification_sounds/" + notification_sound;
$("#notification-sound-source-ogg").attr("src", `${audio_file_without_extension}.ogg`);
$("#notification-sound-source-mp3").attr("src", `${audio_file_without_extension}.mp3`);
@ -233,8 +234,8 @@ export function process_notification(notification) {
if (message.type === "private" || message.type === "test-notification") {
if (
page_params.pm_content_in_desktop_notifications !== undefined &&
!page_params.pm_content_in_desktop_notifications
user_settings.pm_content_in_desktop_notifications !== undefined &&
!user_settings.pm_content_in_desktop_notifications
) {
content = "New private message from " + message.sender_full_name;
}
@ -390,7 +391,7 @@ export function should_send_desktop_notification(message) {
// enable_desktop_notifications determines whether we pop up a
// notification for PMs/mentions/alerts
if (!page_params.enable_desktop_notifications) {
if (!user_settings.enable_desktop_notifications) {
return false;
}
@ -422,7 +423,7 @@ export function should_send_desktop_notification(message) {
export function should_send_audible_notification(message) {
// If `None` is selected as the notification sound, never send
// audible notifications regardless of other configuration.
if (page_params.notification_sound === "none") {
if (user_settings.notification_sound === "none") {
return false;
}
@ -436,7 +437,7 @@ export function should_send_audible_notification(message) {
}
// enable_sounds determines whether we ding for PMs/mentions/alerts
if (!page_params.enable_sounds) {
if (!user_settings.enable_sounds) {
return false;
}
@ -692,7 +693,7 @@ export function handle_global_notification_updates(notification_name, setting) {
// for a given message. These settings do not affect whether or not a
// particular stream should receive notifications.
if (settings_config.all_notification_settings.includes(notification_name)) {
page_params[notification_name] = setting;
user_settings[notification_name] = setting;
}
if (settings_config.stream_notification_settings.includes(notification_name)) {

View File

@ -2,15 +2,6 @@ import $ from "jquery";
const t1 = performance.now();
export const page_params: {
color_scheme: number;
enable_desktop_notifications: boolean;
enable_offline_email_notifications: boolean;
enable_offline_push_notifications: boolean;
enable_sounds: boolean;
enable_stream_audible_notifications: boolean;
enable_stream_desktop_notifications: boolean;
enable_stream_email_notifications: boolean;
enable_stream_push_notifications: boolean;
language_list: {
code: string;
locale: string;
@ -38,8 +29,6 @@ export const page_params: {
server_avatar_changes_disabled: boolean;
server_name_changes_disabled: boolean;
translation_data: Record<string, string>;
twenty_four_hour_time: boolean;
wildcard_mentions_notify: boolean;
zulip_plan_is_not_limited: boolean;
} = $("#page-params").remove().data("params");
const t2 = performance.now();

View File

@ -12,6 +12,7 @@ import * as message_lists from "./message_lists";
import * as message_store from "./message_store";
import {page_params} from "./page_params";
import * as people from "./people";
import {user_settings} from "./user_settings";
export const view = {}; // function namespace
@ -325,7 +326,7 @@ view.insert_new_reaction = function (opts) {
context.count = 1;
context.label = new_label;
context.local_id = get_local_reaction_id(opts);
context.emoji_alt_code = page_params.emojiset === "text";
context.emoji_alt_code = user_settings.emojiset === "text";
if (opts.user_id === page_params.user_id) {
context.class = "message_reaction reacted";
@ -519,7 +520,7 @@ export function add_clean_reaction(opts) {
r.user_ids = opts.user_ids;
update_user_fields(r);
r.emoji_alt_code = page_params.emojiset === "text";
r.emoji_alt_code = user_settings.emojiset === "text";
if (r.reaction_type !== "unicode_emoji") {
r.is_realm_emoji = true;

View File

@ -8,13 +8,13 @@ import view_code_in_playground from "../templates/view_code_in_playground.hbs";
import * as blueslip from "./blueslip";
import {$t, $t_html} from "./i18n";
import {page_params} from "./page_params";
import * as people from "./people";
import * as realm_playground from "./realm_playground";
import * as rtl from "./rtl";
import * as stream_data from "./stream_data";
import * as timerender from "./timerender";
import * as user_groups from "./user_groups";
import {user_settings} from "./user_settings";
/*
rendered_markdown
@ -236,8 +236,8 @@ export const update_elements = (content) => {
});
// Display emoji (including realm emoji) as text if
// page_params.emojiset is 'text'.
if (page_params.emojiset === "text") {
// user_settings.emojiset is 'text'.
if (user_settings.emojiset === "text") {
content.find(".emoji").replaceWith(function () {
const text = $(this).attr("title");
return ":" + text + ":";

View File

@ -7,9 +7,9 @@ import * as message_lists from "./message_lists";
import * as message_viewport from "./message_viewport";
import * as navbar_alerts from "./navbar_alerts";
import * as navigate from "./navigate";
import {page_params} from "./page_params";
import * as popovers from "./popovers";
import * as ui from "./ui";
import {user_settings} from "./user_settings";
import * as util from "./util";
let narrow_window = false;
@ -206,7 +206,7 @@ export function resize_stream_filters_container(h) {
export function resize_sidebars() {
let sidebar;
if (page_params.left_side_userlist) {
if (user_settings.left_side_userlist) {
const css_narrow_mode = message_viewport.is_narrow();
$("#top_navbar").removeClass("rightside-userlist");

View File

@ -1,7 +1,7 @@
import $ from "jquery";
import {media_breakpoints} from "./css_variables";
import {page_params} from "./page_params";
import {user_settings} from "./user_settings";
// A few of our width properties in Zulip depend on the width of the
// browser scrollbar that is generated at the far right side of the
@ -84,7 +84,7 @@ export function set_layout_width() {
// content when reloading a Zulip browser window. More details
// are available in the comments on the max-width of 1400px in
// the .app-main CSS rules.
if (page_params.fluid_layout_width) {
if (user_settings.fluid_layout_width) {
$(".header-main").css("max-width", "inherit");
$(".app .app-main").css("max-width", "inherit");
$(".fixed-app .app-main").css("max-width", "inherit");

View File

@ -63,6 +63,7 @@ import * as typing_events from "./typing_events";
import * as unread_ops from "./unread_ops";
import * as user_events from "./user_events";
import * as user_groups from "./user_groups";
import {user_settings} from "./user_settings";
import * as user_status from "./user_status";
export function dispatch_normal_event(event) {
@ -566,7 +567,7 @@ export function dispatch_normal_event(event) {
"starred_message_counts",
];
if (user_display_settings.includes(event.property)) {
page_params[event.property] = event.value;
user_settings[event.property] = event.value;
}
if (event.property === "default_language") {
// We additionally need to set the language name.
@ -640,8 +641,8 @@ export function dispatch_normal_event(event) {
activity.build_user_sidebar();
}
if (event.property === "enter_sends") {
page_params.enter_sends = event.value;
$("#enter_sends").prop("checked", page_params.enter_sends);
user_settings.enter_sends = event.value;
$("#enter_sends").prop("checked", user_settings.enter_sends);
compose.toggle_enter_sends_ui();
break;
}

View File

@ -20,6 +20,7 @@ import * as settings_display from "./settings_display";
import * as settings_panel_menu from "./settings_panel_menu";
import * as settings_sections from "./settings_sections";
import * as settings_toggle from "./settings_toggle";
import {user_settings} from "./user_settings";
export let settings_label;
@ -102,7 +103,7 @@ export function build_page() {
date_joined_text: get_parsed_date_of_joining(),
page_params,
enable_sound_select:
page_params.enable_sounds || page_params.enable_stream_audible_notifications,
user_settings.enable_sounds || user_settings.enable_stream_audible_notifications,
zuliprc: "zuliprc",
botserverrc: "botserverrc",
timezones: timezones.timezones,
@ -122,7 +123,8 @@ export function build_page() {
user_can_change_avatar: settings_data.user_can_change_avatar(),
user_role_text: people.get_user_type(page_params.user_id),
default_language_name: settings_display.default_language_name,
language_list_dbl_col: get_language_list_columns(page_params.default_language),
language_list_dbl_col: get_language_list_columns(user_settings.default_language),
user_settings,
});
$(".settings-box").html(rendered_settings_tab);

View File

@ -25,6 +25,7 @@ import * as setup from "./setup";
import * as ui_report from "./ui_report";
import * as user_pill from "./user_pill";
import * as user_profile from "./user_profile";
import {user_settings} from "./user_settings";
let password_quality; // Loaded asynchronously
@ -666,7 +667,7 @@ export function set_up() {
avatar.build_user_avatar_widget(upload_avatar);
$("#user_timezone").val(page_params.timezone);
$("#user_timezone").val(user_settings.timezone);
$("#user_timezone").on("change", function (e) {
e.preventDefault();
@ -682,7 +683,7 @@ export function set_up() {
);
});
$("#presence_enabled").val(page_params.presence_enabled);
$("#presence_enabled").val(user_settings.presence_enabled);
$("#presence_enabled").on("change", (e) => {
e.preventDefault();

View File

@ -1,5 +1,6 @@
import {$t} from "./i18n";
import {page_params} from "./page_params";
import {user_settings} from "./user_settings";
/*
This file contains translations between the integer values used in
@ -385,7 +386,7 @@ export const stream_specific_notification_settings = [
"wildcard_mentions_notify",
];
type PageParamsItem = keyof typeof page_params;
type PageParamsItem = keyof typeof user_settings;
export const stream_notification_settings: PageParamsItem[] = [
"enable_stream_desktop_notifications",
"enable_stream_audible_notifications",
@ -444,7 +445,7 @@ export function get_notifications_table_row_data(
};
}
const checked = page_params[setting_name];
const checked = user_settings[setting_name];
if (typeof checked !== "boolean") {
throw new TypeError(`Incorrect setting_name passed: ${setting_name}`);
}

View File

@ -1,5 +1,6 @@
import {page_params} from "./page_params";
import * as settings_config from "./settings_config";
import {user_settings} from "./user_settings";
let user_join_date: Date;
export function initialize(current_user_join_date: Date): void {
@ -75,7 +76,7 @@ export function get_time_preferences(user_timezone: string): {
timezone: string;
format: string;
} {
if (page_params.twenty_four_hour_time) {
if (user_settings.twenty_four_hour_time) {
return {
timezone: user_timezone,
format: "H:mm",
@ -192,12 +193,12 @@ export function user_can_edit_topic_of_any_message(): boolean {
}
export function using_dark_theme(): boolean {
if (page_params.color_scheme === settings_config.color_scheme_values.night.code) {
if (user_settings.color_scheme === settings_config.color_scheme_values.night.code) {
return true;
}
if (
page_params.color_scheme === settings_config.color_scheme_values.automatic.code &&
user_settings.color_scheme === settings_config.color_scheme_values.automatic.code &&
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
) {

View File

@ -5,10 +5,10 @@ import * as emojisets from "./emojisets";
import {$t_html, get_language_name} from "./i18n";
import * as loading from "./loading";
import * as overlays from "./overlays";
import {page_params} from "./page_params";
import * as settings_config from "./settings_config";
import * as settings_ui from "./settings_ui";
import * as ui_report from "./ui_report";
import {user_settings} from "./user_settings";
const meta = {
loaded: false,
@ -42,15 +42,15 @@ export function set_up() {
meta.loaded = true;
$("#display-settings-status").hide();
$("#demote_inactive_streams").val(page_params.demote_inactive_streams);
$("#demote_inactive_streams").val(user_settings.demote_inactive_streams);
$("#color_scheme").val(page_params.color_scheme);
$("#color_scheme").val(user_settings.color_scheme);
$("#default_view").val(page_params.default_view);
$("#default_view").val(user_settings.default_view);
$("#twenty_four_hour_time").val(JSON.stringify(page_params.twenty_four_hour_time));
$("#twenty_four_hour_time").val(JSON.stringify(user_settings.twenty_four_hour_time));
$(`.emojiset_choice[value="${CSS.escape(page_params.emojiset)}"]`).prop("checked", true);
$(`.emojiset_choice[value="${CSS.escape(user_settings.emojiset)}"]`).prop("checked", true);
$("#default_language_modal [data-dismiss]").on("click", () => {
overlays.close_modal("#default_language_modal");
@ -139,7 +139,7 @@ export function set_up() {
$(".emojiset_choice").on("click", function () {
const data = {emojiset: $(this).val()};
const current_emojiset = page_params.emojiset;
const current_emojiset = user_settings.emojiset;
if (current_emojiset === data.emojiset) {
return;
}
@ -174,11 +174,11 @@ export async function report_emojiset_change() {
// implementation is wrong, though, in that it displays the UI
// update in all active browser windows.
await emojisets.select(page_params.emojiset);
await emojisets.select(user_settings.emojiset);
if ($("#emoji-settings-status").length) {
loading.destroy_indicator($("#emojiset_spinner"));
$("#emojiset_select").val(page_params.emojiset);
$("#emojiset_select").val(user_settings.emojiset);
ui_report.success(
$t_html({defaultMessage: "Emojiset changed successfully!"}),
$("#emoji-settings-status").expectOne(),
@ -189,18 +189,18 @@ export async function report_emojiset_change() {
}
export function update_page() {
$("#left_side_userlist").prop("checked", page_params.left_side_userlist);
$("#left_side_userlist").prop("checked", user_settings.left_side_userlist);
$("#default_language_name").text(default_language_name);
$("#translate_emoticons").prop("checked", page_params.translate_emoticons);
$("#twenty_four_hour_time").val(JSON.stringify(page_params.twenty_four_hour_time));
$("#color_scheme").val(JSON.stringify(page_params.color_scheme));
$("#default_view").val(page_params.default_view);
$("#translate_emoticons").prop("checked", user_settings.translate_emoticons);
$("#twenty_four_hour_time").val(JSON.stringify(user_settings.twenty_four_hour_time));
$("#color_scheme").val(JSON.stringify(user_settings.color_scheme));
$("#default_view").val(user_settings.default_view);
// TODO: Set emojiset selector here.
// Longer term, we'll want to automate this function
}
export function initialize() {
const language_name = get_language_name(page_params.default_language);
const language_name = get_language_name(user_settings.default_language);
set_default_language_name(language_name);
}

View File

@ -5,13 +5,13 @@ import render_stream_specific_notification_row from "../templates/settings/strea
import * as channel from "./channel";
import {$t} from "./i18n";
import * as notifications from "./notifications";
import {page_params} from "./page_params";
import * as settings_config from "./settings_config";
import * as settings_org from "./settings_org";
import * as settings_ui from "./settings_ui";
import * as stream_edit from "./stream_edit";
import * as stream_settings_data from "./stream_settings_data";
import * as unread_ui from "./unread_ui";
import {user_settings} from "./user_settings";
function rerender_ui() {
const unmatched_streams_table = $("#stream-specific-notify-table");
@ -50,12 +50,12 @@ function change_notification_setting(setting, value, status_element) {
}
function update_desktop_icon_count_display() {
$("#desktop_icon_count_display").val(page_params.desktop_icon_count_display);
$("#desktop_icon_count_display").val(user_settings.desktop_icon_count_display);
unread_ui.update_unread_counts();
}
export function set_enable_digest_emails_visibility() {
if (page_params.realm_digest_emails_enabled) {
if (user_settings.realm_digest_emails_enabled) {
$("#enable_digest_emails_label").parent().show();
} else {
$("#enable_digest_emails_label").parent().hide();
@ -63,7 +63,7 @@ export function set_enable_digest_emails_visibility() {
}
export function set_enable_marketing_emails_visibility() {
if (page_params.corporate_enabled) {
if (user_settings.corporate_enabled) {
$("#enable_marketing_emails_label").parent().show();
} else {
$("#enable_marketing_emails_label").parent().hide();
@ -96,13 +96,13 @@ export function set_up() {
});
$("#play_notification_sound").on("click", () => {
if (page_params.notification_sound !== "none") {
if (user_settings.notification_sound !== "none") {
$("#notification-sound-audio")[0].play();
}
});
const notification_sound_dropdown = $("#notification_sound");
notification_sound_dropdown.val(page_params.notification_sound);
notification_sound_dropdown.val(user_settings.notification_sound);
$("#enable_sounds, #enable_stream_audible_notifications").on("change", () => {
if (
@ -125,7 +125,7 @@ export function update_page() {
for (const setting of settings_config.all_notification_settings) {
if (
setting === "enable_offline_push_notifications" &&
!page_params.realm_push_notifications_enabled
!user_settings.realm_push_notifications_enabled
) {
// If push notifications are disabled at the realm level,
// we should just leave the checkbox always off.
@ -135,7 +135,7 @@ export function update_page() {
continue;
}
$(`#${CSS.escape(setting)}`).prop("checked", page_params[setting]);
$(`#${CSS.escape(setting)}`).prop("checked", user_settings[setting]);
}
rerender_ui();
}

View File

@ -2,6 +2,7 @@ import * as message_store from "./message_store";
import {page_params} from "./page_params";
import * as stream_popover from "./stream_popover";
import * as top_left_corner from "./top_left_corner";
import {user_settings} from "./user_settings";
export const starred_ids = new Set();
@ -74,7 +75,7 @@ export function get_count_in_topic(stream_id, topic) {
export function rerender_ui() {
let count = get_count();
if (!page_params.starred_message_counts) {
if (!user_settings.starred_message_counts) {
// This essentially hides the count
count = 0;
}

View File

@ -8,6 +8,7 @@ import * as people from "./people";
import * as settings_config from "./settings_config";
import * as stream_topic_history from "./stream_topic_history";
import * as sub_store from "./sub_store";
import {user_settings} from "./user_settings";
import * as util from "./util";
const DEFAULT_COLOR = "#c2c2c2";
@ -160,12 +161,12 @@ clear_subscriptions();
export function set_filter_out_inactives() {
if (
page_params.demote_inactive_streams ===
user_settings.demote_inactive_streams ===
settings_config.demote_inactive_streams_values.automatic.code
) {
filter_out_inactives = num_subscribed_subs() >= 30;
} else if (
page_params.demote_inactive_streams ===
user_settings.demote_inactive_streams ===
settings_config.demote_inactive_streams_values.always.code
) {
filter_out_inactives = true;
@ -457,9 +458,9 @@ export function receives_notifications(stream_id, notification_name) {
return sub[notification_name];
}
if (notification_name === "wildcard_mentions_notify") {
return page_params[notification_name];
return user_settings[notification_name];
}
return page_params["enable_stream_" + notification_name];
return user_settings["enable_stream_" + notification_name];
}
export function all_subscribed_streams_are_in_home_view() {
@ -672,11 +673,11 @@ export function create_sub_from_server_data(attrs) {
newly_subscribed: false,
is_muted: false,
invite_only: false,
desktop_notifications: page_params.enable_stream_desktop_notifications,
audible_notifications: page_params.enable_stream_audible_notifications,
push_notifications: page_params.enable_stream_push_notifications,
email_notifications: page_params.enable_stream_email_notifications,
wildcard_mentions_notify: page_params.wildcard_mentions_notify,
desktop_notifications: user_settings.enable_stream_desktop_notifications,
audible_notifications: user_settings.enable_stream_audible_notifications,
push_notifications: user_settings.enable_stream_push_notifications,
email_notifications: user_settings.enable_stream_email_notifications,
wildcard_mentions_notify: user_settings.wildcard_mentions_notify,
description: "",
rendered_description: "",
first_message_id: attrs.first_message_id,

View File

@ -38,6 +38,7 @@ import * as ui from "./ui";
import * as ui_report from "./ui_report";
import * as user_group_pill from "./user_group_pill";
import * as user_pill from "./user_pill";
import {user_settings} from "./user_settings";
import * as util from "./util";
export let pill_widget;
@ -592,9 +593,9 @@ export function stream_setting_changed(e, from_notification_settings) {
}
if (is_notification_setting(setting) && sub[setting] === null) {
if (setting === "wildcard_mentions_notify") {
sub[setting] = page_params[setting];
sub[setting] = user_settings[setting];
} else {
sub[setting] = page_params["enable_stream_" + setting];
sub[setting] = user_settings["enable_stream_" + setting];
}
}
set_stream_property(sub, setting, e.target.checked, status_element);

View File

@ -32,6 +32,7 @@ import * as stream_data from "./stream_data";
import * as stream_settings_ui from "./stream_settings_ui";
import * as sub_store from "./sub_store";
import * as unread_ops from "./unread_ops";
import {user_settings} from "./user_settings";
// We handle stream popovers and topic popovers in this
// module. Both are popped up from the left sidebar.
@ -332,7 +333,7 @@ function build_starred_messages_popover(e) {
const show_unstar_all_button = starred_messages.get_count() > 0;
const content = render_starred_messages_sidebar_actions({
show_unstar_all_button,
starred_message_counts: page_params.starred_message_counts,
starred_message_counts: user_settings.starred_message_counts,
});
$(elt).popover({
@ -506,7 +507,7 @@ export function register_stream_handlers() {
hide_starred_messages_popover();
e.preventDefault();
e.stopPropagation();
const starred_msg_counts = page_params.starred_message_counts;
const starred_msg_counts = user_settings.starred_message_counts;
const data = {};
data.starred_message_counts = JSON.stringify(!starred_msg_counts);
channel.patch({

View File

@ -4,6 +4,7 @@ import * as peer_data from "./peer_data";
import * as settings_config from "./settings_config";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
import {user_settings} from "./user_settings";
import * as util from "./util";
export function get_sub_for_settings(sub) {
@ -61,7 +62,7 @@ export function get_unmatched_streams_for_notification_settings() {
for (const notification_name of settings_config.stream_specific_notification_settings) {
const prepend =
notification_name === "wildcard_mentions_notify" ? "" : "enable_stream_";
const default_setting = page_params[prepend + notification_name];
const default_setting = user_settings[prepend + notification_name];
const stream_setting = stream_data.receives_notifications(
row.stream_id,
notification_name,

View File

@ -14,7 +14,7 @@ import _ from "lodash";
import render_markdown_time_tooltip from "../templates/markdown_time_tooltip.hbs";
import {$t} from "./i18n";
import {page_params} from "./page_params";
import {user_settings} from "./user_settings";
let next_timerender_id = 0;
@ -206,7 +206,7 @@ export function render_date(time, time_above, today) {
// Renders the timestamp returned by the <time:> Markdown syntax.
export function render_markdown_timestamp(time) {
const hourformat = page_params.twenty_four_hour_time ? "HH:mm" : "h:mm a";
const hourformat = user_settings.twenty_four_hour_time ? "HH:mm" : "h:mm a";
const timestring = format(time, "E, MMM d yyyy, " + hourformat);
const tz_offset_str = get_tz_with_UTC_offset(time);
@ -277,7 +277,7 @@ export function get_timestamp_for_flatpickr(timestring) {
}
export function stringify_time(time) {
if (page_params.twenty_four_hour_time) {
if (user_settings.twenty_four_hour_time) {
return format(time, "HH:mm");
}
return format(time, "h:mm a");
@ -324,7 +324,7 @@ export const absolute_time = (function () {
return function (timestamp, today = new Date()) {
const date = new Date(timestamp);
const is_older_year = today.getFullYear() - date.getFullYear() > 0;
const H_24 = page_params.twenty_four_hour_time;
const H_24 = user_settings.twenty_four_hour_time;
let str = MONTHS[date.getMonth()] + " " + date.getDate();
// include year if message date is from a previous year
if (is_older_year) {
@ -338,7 +338,7 @@ export const absolute_time = (function () {
export function get_full_datetime(time) {
const time_options = {timeStyle: "medium"};
if (page_params.twenty_four_hour_time) {
if (user_settings.twenty_four_hour_time) {
time_options.hourCycle = "h24";
}

View File

@ -88,6 +88,7 @@ import * as ui from "./ui";
import * as unread from "./unread";
import * as unread_ui from "./unread_ui";
import * as user_groups from "./user_groups";
import {initialize_user_settings, user_settings} from "./user_settings";
import * as user_status from "./user_status";
import * as user_status_ui from "./user_status_ui";
@ -228,15 +229,15 @@ export function initialize_kitchen_sink_stuff() {
$("body").addClass("spectator-view");
}
if (!page_params.left_side_userlist) {
if (!user_settings.left_side_userlist) {
$("#navbar-buttons").addClass("right-userlist");
}
if (page_params.high_contrast_mode) {
if (user_settings.high_contrast_mode) {
$("body").addClass("high-contrast");
}
if (!page_params.dense_mode) {
if (!user_settings.dense_mode) {
$("body").addClass("less_dense_mode");
} else {
$("body").addClass("more_dense_mode");
@ -493,11 +494,13 @@ export function initialize_everything() {
const user_status_params = pop_fields("user_status");
const i18n_params = pop_fields("language_list");
const user_settings_params = pop_fields("user_settings");
i18n.initialize(i18n_params);
tippyjs.initialize();
popover_menus.initialize();
initialize_user_settings(user_settings_params);
people.initialize(page_params.user_id, people_params);
let date_joined;

View File

@ -6,6 +6,7 @@ import * as people from "./people";
import * as settings_config from "./settings_config";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
import {user_settings} from "./user_settings";
import * as util from "./util";
// The unread module tracks the message IDs and locations of the
@ -509,10 +510,10 @@ export function calculate_notifiable_count(res) {
let new_message_count = 0;
const only_show_notifiable =
page_params.desktop_icon_count_display ===
user_settings.desktop_icon_count_display ===
settings_config.desktop_icon_count_display_values.notifiable.code;
const no_notifications =
page_params.desktop_icon_count_display ===
user_settings.desktop_icon_count_display ===
settings_config.desktop_icon_count_display_values.none.code;
if (only_show_notifiable) {
// DESKTOP_ICON_COUNT_DISPLAY_NOTIFIABLE

View File

@ -0,0 +1,19 @@
type UserSettingsType = {
color_scheme: number;
enable_desktop_notifications: boolean;
enable_offline_push_notifications: boolean;
enable_offline_email_notifications: boolean;
enable_sounds: boolean;
enable_stream_audible_notifications: boolean;
enable_stream_desktop_notifications: boolean;
enable_stream_email_notifications: boolean;
enable_stream_push_notifications: boolean;
twenty_four_hour_time: boolean;
wildcard_mentions_notify: boolean;
};
export let user_settings = {} as UserSettingsType;
export function initialize_user_settings(params: Record<string, UserSettingsType>): void {
user_settings = params.user_settings;
}

View File

@ -2,7 +2,7 @@ import * as emoji from "../shared/js/emoji";
import * as blueslip from "./blueslip";
import * as channel from "./channel";
import {page_params} from "./page_params";
import {user_settings} from "./user_settings";
const away_user_ids = new Set();
const user_info = new Map();
@ -80,7 +80,7 @@ export function set_status_emoji(opts) {
emoji_name: opts.emoji_name,
emoji_code: opts.emoji_code,
reaction_type: opts.reaction_type,
emoji_alt_code: page_params.emojiset === "text",
emoji_alt_code: user_settings.emojiset === "text",
...emoji.get_emoji_details_by_name(opts.emoji_name),
});
}

View File

@ -43,8 +43,8 @@ function build_emoticon_translations() {
....
]
We build up this list of ~12 emoticon translations
even if page_params.translate_emoticons is false, since
We build up this list of ~12 emoticon translations even
if user_settings.translate_emoticons is false, since
that setting can be flipped via live update events.
On the other hand, we assume that emoticon_conversions
won't change until the next reload, which is fine for

View File

@ -101,7 +101,7 @@
<div class="input-group">
{{> settings_checkbox
setting_name="presence_enabled"
is_checked=page_params.presence_enabled
is_checked=user_settings.presence_enabled
label=settings_label.presence_enabled
help_link="/help/status-and-availability"}}
</div>

View File

@ -41,7 +41,7 @@
{{#each display_settings.settings.user_display_settings}}
{{> settings_checkbox
setting_name=this
is_checked=(lookup ../page_params this)
is_checked=(lookup ../user_settings this)
label=(lookup ../settings_label this)
render_only=(lookup ../display_settings.render_only this)}}
{{/each}}
@ -76,7 +76,7 @@
<div class="input-group">
<div class="emojiset_choices grey-box">
{{#each page_params.emojiset_choices}}
{{#each user_settings.emojiset_choices}}
<label>
<input type="radio" class="emojiset_choice" name="emojiset_group" value="{{this.key}}" />
<span>{{this.text}}</span>
@ -97,7 +97,7 @@
{{> settings_checkbox
setting_name="translate_emoticons"
is_checked=page_params.translate_emoticons
is_checked=user_settings.translate_emoticons
label=settings_label.translate_emoticons}}
</div>
</form>

View File

@ -56,7 +56,7 @@
{{#each notification_settings.desktop_notification_settings}}
{{> settings_checkbox
setting_name=this
is_checked=(lookup ../page_params this)
is_checked=(lookup ../user_settings this)
label=(lookup ../settings_label this)}}
{{/each}}
@ -70,7 +70,7 @@
disabled
{{/unless}}>
<option value="none">{{t "None" }}</option>
{{#each page_params.available_notification_sounds}}
{{#each user_settings.available_notification_sounds}}
<option value="{{ this }}">{{ this }}</option>
{{/each}}
</select>
@ -92,7 +92,7 @@
{{#each notification_settings.mobile_notification_settings}}
{{> settings_checkbox
setting_name=this
is_checked=(lookup ../page_params this)
is_checked=(lookup ../user_settings this)
label=(lookup ../settings_label this)
show_push_notifications_tooltip=(lookup ../show_push_notifications_tooltip this)}}
{{/each}}
@ -102,7 +102,7 @@
{{#each notification_settings.email_notification_settings}}
{{> settings_checkbox
setting_name=this
is_checked=(lookup ../page_params this)
is_checked=(lookup ../user_settings this)
label=(lookup ../settings_label this)}}
{{/each}}

View File

@ -33,7 +33,7 @@
<div class="alert-notification timezone-setting-status"></div>
<div class="timezone-input">
<select name="timezone" id="user_timezone" class>
{{#unless page_params.timezone}}
{{#unless user_settings.timezone}}
<option></option>
{{/unless}}

View File

@ -175,6 +175,7 @@ EXEMPT_FILES = {
"static/js/unread_ui.js",
"static/js/upload_widget.ts",
"static/js/user_profile.js",
"static/js/user_settings.ts",
"static/js/user_status_ui.js",
"static/js/webpack_public_path.js",
"static/js/zcommand.js",

View File

@ -424,7 +424,7 @@ BAD_HTML16 = """
<div>
{{> settings_checkbox
setting_name="realm_name_in_notifications"
is_checked=page_params.realm_name_in_notifications
is_checked=user_settings.realm_name_in_notifications
label=settings_label.realm_name_in_notifications}}
</div>
"""
@ -433,7 +433,7 @@ GOOD_HTML16 = """
<div>
{{> settings_checkbox
setting_name="realm_name_in_notifications"
is_checked=page_params.realm_name_in_notifications
is_checked=user_settings.realm_name_in_notifications
label=settings_label.realm_name_in_notifications}}
</div>
"""

View File

@ -135,7 +135,7 @@ def build_page_params_for_home_page_load(
"bulk_message_deletion": True,
"user_avatar_url_field_optional": True,
"stream_typing_notifications": False, # Set this to True when frontend support is implemented.
"user_settings_object": False, # Set this to True when frontend support is implemented.
"user_settings_object": True,
}
if user_profile is not None:
@ -176,7 +176,7 @@ def build_page_params_for_home_page_load(
request_language = get_and_set_request_language(
request,
register_ret["default_language"],
register_ret["user_settings"]["default_language"],
translation.get_language_from_path(request.path_info),
)
@ -234,7 +234,7 @@ def build_page_params_for_home_page_load(
page_params["narrow_topic"] = narrow_topic
page_params["narrow"] = [dict(operator=term[0], operand=term[1]) for term in narrow]
page_params["max_message_id"] = max_message_id
page_params["enable_desktop_notifications"] = False
page_params["user_settings"]["enable_desktop_notifications"] = False
page_params["translation_data"] = get_language_translation_data(request_language)

View File

@ -45,7 +45,6 @@ class HomeTest(ZulipTestCase):
expected_page_params_keys = [
"alert_words",
"apps_page_url",
"available_notification_sounds",
"avatar_source",
"avatar_url",
"avatar_url_medium",
@ -53,46 +52,21 @@ class HomeTest(ZulipTestCase):
"can_create_streams",
"can_invite_others_to_realm",
"can_subscribe_other_users",
"color_scheme",
"corporate_enabled",
"cross_realm_bots",
"custom_profile_field_types",
"custom_profile_fields",
"default_language",
"default_view",
"delivery_email",
"demote_inactive_streams",
"dense_mode",
"desktop_icon_count_display",
"development_environment",
"drafts",
"email",
"email_notifications_batching_period_seconds",
"emojiset",
"emojiset_choices",
"enable_desktop_notifications",
"enable_digest_emails",
"enable_drafts_synchronization",
"enable_login_emails",
"enable_marketing_emails",
"enable_offline_email_notifications",
"enable_offline_push_notifications",
"enable_online_push_notifications",
"enable_sounds",
"enable_stream_audible_notifications",
"enable_stream_desktop_notifications",
"enable_stream_email_notifications",
"enable_stream_push_notifications",
"enter_sends",
"event_queue_longpoll_timeout_seconds",
"first_in_realm",
"fluid_layout_width",
"full_name",
"furthest_read_time",
"giphy_api_key",
"giphy_rating_options",
"has_zoom_token",
"high_contrast_mode",
"hotspots",
"insecure_desktop_app",
"is_admin",
@ -104,7 +78,6 @@ class HomeTest(ZulipTestCase):
"jitsi_server_url",
"language_list",
"last_event_id",
"left_side_userlist",
"login_page",
"max_avatar_file_size_mib",
"max_file_upload_size_mib",
@ -115,7 +88,6 @@ class HomeTest(ZulipTestCase):
"max_stream_description_length",
"max_stream_name_length",
"max_topic_length",
"message_content_in_email_notifications",
"muted_topics",
"muted_users",
"narrow",
@ -123,11 +95,8 @@ class HomeTest(ZulipTestCase):
"needs_tutorial",
"never_subscribed",
"no_event_queue",
"notification_sound",
"password_min_guesses",
"password_min_length",
"pm_content_in_desktop_notifications",
"presence_enabled",
"presences",
"promote_sponsoring_zulip",
"prompt_for_invites",
@ -184,7 +153,6 @@ class HomeTest(ZulipTestCase):
"realm_move_messages_between_streams_policy",
"realm_name",
"realm_name_changes_disabled",
"realm_name_in_notifications",
"realm_night_logo_source",
"realm_night_logo_url",
"realm_non_active_users",
@ -219,15 +187,11 @@ class HomeTest(ZulipTestCase):
"show_billing",
"show_plans",
"show_webathena",
"starred_message_counts",
"starred_messages",
"stop_words",
"subscriptions",
"test_suite",
"timezone",
"translate_emoticons",
"translation_data",
"twenty_four_hour_time",
"two_fa_enabled",
"two_fa_enabled_user",
"unread_msgs",
@ -238,7 +202,6 @@ class HomeTest(ZulipTestCase):
"user_status",
"warn_no_email",
"webpack_public_path",
"wildcard_mentions_notify",
"zulip_feature_level",
"zulip_merge_base",
"zulip_plan_is_not_limited",
@ -1030,7 +993,7 @@ class HomeTest(ZulipTestCase):
):
result = self.client_get("/de/")
page_params = self._get_page_params(result)
self.assertEqual(page_params["default_language"], "es")
self.assertEqual(page_params["user_settings"]["default_language"], "es")
# TODO: Verify that the actual language we're using in the
# translation data is German.
@ -1043,7 +1006,7 @@ class HomeTest(ZulipTestCase):
self.check_rendered_logged_in_app(result)
page_params = self._get_page_params(result)
self.assertEqual(page_params["default_language"], "es")
self.assertEqual(page_params["user_settings"]["default_language"], "es")
# TODO: This test would likely be better written as a /register
# API test with just the drafts event type, to avoid the
@ -1076,7 +1039,7 @@ class HomeTest(ZulipTestCase):
# recently edited ones.
self.login("hamlet")
page_params = self._get_page_params(self._get_home_page())
self.assertEqual(page_params["enable_drafts_synchronization"], True)
self.assertEqual(page_params["user_settings"]["enable_drafts_synchronization"], True)
self.assert_length(page_params["drafts"], settings.MAX_DRAFTS_IN_REGISTER_RESPONSE)
self.assertEqual(
Draft.objects.count(), settings.MAX_DRAFTS_IN_REGISTER_RESPONSE + 1 + initial_count