mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 19:06:09 +00:00
home: Get page_params.enable_desktop_notifications from register_ret.
This commit is contained in:
@@ -51,7 +51,7 @@ i18n.init({
|
|||||||
twenty_four_hour_time: false,
|
twenty_four_hour_time: false,
|
||||||
enable_stream_desktop_notifications: false,
|
enable_stream_desktop_notifications: false,
|
||||||
enable_stream_sounds: false,
|
enable_stream_sounds: false,
|
||||||
desktop_notifications_enabled: false,
|
enable_desktop_notifications: false,
|
||||||
enable_sounds: false,
|
enable_sounds: false,
|
||||||
enable_offline_email_notifications: false,
|
enable_offline_email_notifications: false,
|
||||||
enable_offline_push_notifications: false,
|
enable_offline_push_notifications: false,
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ function render(template_name, args) {
|
|||||||
(function settings_tab() {
|
(function settings_tab() {
|
||||||
var page_param_checkbox_options = {
|
var page_param_checkbox_options = {
|
||||||
enable_stream_desktop_notifications: true,
|
enable_stream_desktop_notifications: true,
|
||||||
enable_stream_sounds: true, desktop_notifications_enabled: true,
|
enable_stream_sounds: true, enable_desktop_notifications: true,
|
||||||
enable_sounds: true, enable_offline_email_notifications: true,
|
enable_sounds: true, enable_offline_email_notifications: true,
|
||||||
enable_offline_push_notifications: true, enable_online_push_notifications: true,
|
enable_offline_push_notifications: true, enable_online_push_notifications: true,
|
||||||
enable_digest_emails: true,
|
enable_digest_emails: true,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ exports.initialize = function () {
|
|||||||
|
|
||||||
if (notifications_api) {
|
if (notifications_api) {
|
||||||
$(document).click(function () {
|
$(document).click(function () {
|
||||||
if (!page_params.desktop_notifications_enabled || asked_permission_already) {
|
if (!page_params.enable_desktop_notifications || asked_permission_already) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (notifications_api.checkPermission() !== 0) { // 0 is PERMISSION_ALLOWED
|
if (notifications_api.checkPermission() !== 0) { // 0 is PERMISSION_ALLOWED
|
||||||
@@ -441,19 +441,19 @@ function should_send_desktop_notification(message) {
|
|||||||
// For PMs and @-mentions, send if desktop notifications are
|
// For PMs and @-mentions, send if desktop notifications are
|
||||||
// enabled.
|
// enabled.
|
||||||
if ((message.type === "private") &&
|
if ((message.type === "private") &&
|
||||||
page_params.desktop_notifications_enabled) {
|
page_params.enable_desktop_notifications) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For alert words and @-mentions, send if desktop notifications
|
// For alert words and @-mentions, send if desktop notifications
|
||||||
// are enabled.
|
// are enabled.
|
||||||
if (alert_words.notifies(message) &&
|
if (alert_words.notifies(message) &&
|
||||||
page_params.desktop_notifications_enabled) {
|
page_params.enable_desktop_notifications) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exports.speaking_at_me(message) &&
|
if (exports.speaking_at_me(message) &&
|
||||||
page_params.desktop_notifications_enabled) {
|
page_params.enable_desktop_notifications) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,7 +640,7 @@ exports.handle_global_notification_updates = function (notification_name, settin
|
|||||||
} else if (notification_name === "enable_stream_sounds") {
|
} else if (notification_name === "enable_stream_sounds") {
|
||||||
page_params.enable_stream_sounds = setting;
|
page_params.enable_stream_sounds = setting;
|
||||||
} else if (notification_name === "enable_desktop_notifications") {
|
} else if (notification_name === "enable_desktop_notifications") {
|
||||||
page_params.desktop_notifications_enabled = setting;
|
page_params.enable_desktop_notifications = setting;
|
||||||
} else if (notification_name === "enable_sounds") {
|
} else if (notification_name === "enable_sounds") {
|
||||||
page_params.enable_sounds = setting;
|
page_params.enable_sounds = setting;
|
||||||
} else if (notification_name === "enable_offline_email_notifications") {
|
} else if (notification_name === "enable_offline_email_notifications") {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ exports.set_up = function () {
|
|||||||
// PM and @-mention notification settings.
|
// PM and @-mention notification settings.
|
||||||
|
|
||||||
if (result.enable_desktop_notifications !== undefined) {
|
if (result.enable_desktop_notifications !== undefined) {
|
||||||
page_params.desktop_notifications_enabled = result.enable_desktop_notifications;
|
page_params.enable_desktop_notifications = result.enable_desktop_notifications;
|
||||||
}
|
}
|
||||||
if (result.enable_sounds !== undefined) {
|
if (result.enable_sounds !== undefined) {
|
||||||
page_params.enable_sounds = result.enable_sounds;
|
page_params.enable_sounds = result.enable_sounds;
|
||||||
@@ -144,7 +144,7 @@ exports.set_up = function () {
|
|||||||
function _update_page() {
|
function _update_page() {
|
||||||
$("#enable_stream_desktop_notifications").prop('checked', page_params.enable_stream_desktop_notifications);
|
$("#enable_stream_desktop_notifications").prop('checked', page_params.enable_stream_desktop_notifications);
|
||||||
$("#enable_stream_sounds").prop('checked', page_params.enable_stream_sounds);
|
$("#enable_stream_sounds").prop('checked', page_params.enable_stream_sounds);
|
||||||
$("#enable_desktop_notifications").prop('checked', page_params.desktop_notifications_enabled);
|
$("#enable_desktop_notifications").prop('checked', page_params.enable_desktop_notifications);
|
||||||
$("#enable_sounds").prop('checked', page_params.enable_sounds);
|
$("#enable_sounds").prop('checked', page_params.enable_sounds);
|
||||||
$("#enable_offline_email_notifications").prop('checked', page_params.enable_offline_email_notifications);
|
$("#enable_offline_email_notifications").prop('checked', page_params.enable_offline_email_notifications);
|
||||||
$("#enable_offline_push_notifications").prop('checked', page_params.enable_offline_push_notifications);
|
$("#enable_offline_push_notifications").prop('checked', page_params.enable_offline_push_notifications);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" name="enable_desktop_notifications" id="enable_desktop_notifications"
|
<input type="checkbox" name="enable_desktop_notifications" id="enable_desktop_notifications"
|
||||||
{{#if page_params.desktop_notifications_enabled}}
|
{{#if page_params.enable_desktop_notifications}}
|
||||||
checked="checked"
|
checked="checked"
|
||||||
{{/if}} />
|
{{/if}} />
|
||||||
<span></span>
|
<span></span>
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ class HomeTest(ZulipTestCase):
|
|||||||
"default_desktop_notifications",
|
"default_desktop_notifications",
|
||||||
"default_language",
|
"default_language",
|
||||||
"default_language_name",
|
"default_language_name",
|
||||||
"desktop_notifications_enabled",
|
|
||||||
"development_environment",
|
"development_environment",
|
||||||
"email",
|
"email",
|
||||||
"emoji_alt_code",
|
"emoji_alt_code",
|
||||||
"emojiset",
|
"emojiset",
|
||||||
"emojiset_choices",
|
"emojiset_choices",
|
||||||
|
"enable_desktop_notifications",
|
||||||
"enable_digest_emails",
|
"enable_digest_emails",
|
||||||
"enable_offline_email_notifications",
|
"enable_offline_email_notifications",
|
||||||
"enable_offline_push_notifications",
|
"enable_offline_push_notifications",
|
||||||
|
|||||||
@@ -172,10 +172,6 @@ def home_real(request):
|
|||||||
logging.warning("%s has invalid pointer %s" % (user_profile.email, user_profile.pointer))
|
logging.warning("%s has invalid pointer %s" % (user_profile.email, user_profile.pointer))
|
||||||
latest_read = None
|
latest_read = None
|
||||||
|
|
||||||
desktop_notifications_enabled = user_profile.enable_desktop_notifications
|
|
||||||
if narrow_stream is not None:
|
|
||||||
desktop_notifications_enabled = False
|
|
||||||
|
|
||||||
if user_profile.realm.notifications_stream:
|
if user_profile.realm.notifications_stream:
|
||||||
notifications_stream = user_profile.realm.notifications_stream.name
|
notifications_stream = user_profile.realm.notifications_stream.name
|
||||||
else:
|
else:
|
||||||
@@ -219,9 +215,6 @@ def home_real(request):
|
|||||||
autoscroll_forever = user_profile.autoscroll_forever,
|
autoscroll_forever = user_profile.autoscroll_forever,
|
||||||
default_desktop_notifications = user_profile.default_desktop_notifications,
|
default_desktop_notifications = user_profile.default_desktop_notifications,
|
||||||
|
|
||||||
# Private message and @-mention notification settings:
|
|
||||||
desktop_notifications_enabled = desktop_notifications_enabled,
|
|
||||||
|
|
||||||
# Realm foreign key data from register_ret.
|
# Realm foreign key data from register_ret.
|
||||||
# TODO: Rename these to match register_ret values.
|
# TODO: Rename these to match register_ret values.
|
||||||
initial_pointer = register_ret['pointer'],
|
initial_pointer = register_ret['pointer'],
|
||||||
@@ -255,6 +248,7 @@ def home_real(request):
|
|||||||
'emoji_alt_code',
|
'emoji_alt_code',
|
||||||
'emojiset',
|
'emojiset',
|
||||||
'emojiset_choices',
|
'emojiset_choices',
|
||||||
|
'enable_desktop_notifications',
|
||||||
'enable_digest_emails',
|
'enable_digest_emails',
|
||||||
'enable_offline_email_notifications',
|
'enable_offline_email_notifications',
|
||||||
'enable_offline_push_notifications',
|
'enable_offline_push_notifications',
|
||||||
@@ -329,6 +323,7 @@ def home_real(request):
|
|||||||
page_params["max_message_id"] = initial_pointer
|
page_params["max_message_id"] = initial_pointer
|
||||||
page_params["initial_pointer"] = initial_pointer
|
page_params["initial_pointer"] = initial_pointer
|
||||||
page_params["have_initial_messages"] = (initial_pointer != -1)
|
page_params["have_initial_messages"] = (initial_pointer != -1)
|
||||||
|
page_params["enable_desktop_notifications"] = False
|
||||||
|
|
||||||
statsd.incr('views.home')
|
statsd.incr('views.home')
|
||||||
show_invites = True
|
show_invites = True
|
||||||
|
|||||||
Reference in New Issue
Block a user