mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
parent
c2248a81dc
commit
fa44d2ea69
@ -55,7 +55,6 @@ i18n.init({
|
||||
enable_offline_push_notifications: false,
|
||||
enable_online_push_notifications: false,
|
||||
enable_digest_emails: false,
|
||||
autoscroll_forever: false,
|
||||
default_desktop_notifications: false,
|
||||
},
|
||||
};
|
||||
|
||||
@ -958,7 +958,7 @@ function render(template_name, args) {
|
||||
enable_sounds: true, enable_offline_email_notifications: true,
|
||||
enable_offline_push_notifications: true, enable_online_push_notifications: true,
|
||||
enable_digest_emails: true,
|
||||
autoscroll_forever: true, default_desktop_notifications: true,
|
||||
default_desktop_notifications: true,
|
||||
};
|
||||
var page_params = $.extend(page_param_checkbox_options, {
|
||||
full_name: "Alyssa P. Hacker", password_auth_enabled: true,
|
||||
@ -970,7 +970,7 @@ function render(template_name, args) {
|
||||
"enable_stream_sounds", "enable_desktop_notifications",
|
||||
"enable_sounds", "enable_offline_push_notifications",
|
||||
"enable_online_push_notifications",
|
||||
"enable_digest_emails", "autoscroll_forever",
|
||||
"enable_digest_emails",
|
||||
"default_desktop_notifications"];
|
||||
|
||||
// Render with all booleans set to true.
|
||||
|
||||
@ -475,8 +475,6 @@ MessageListView.prototype = {
|
||||
var list = this.list; // for convenience
|
||||
var table_name = this.table_name;
|
||||
var table = rows.get_table(table_name);
|
||||
// we we record if last_message_was_selected before updating the table
|
||||
var last_message_was_selected = rows.id(rows.last_visible()) === list.selected_id();
|
||||
var orig_scrolltop_offset;
|
||||
var message_containers;
|
||||
|
||||
@ -654,13 +652,12 @@ MessageListView.prototype = {
|
||||
}
|
||||
|
||||
if (list === current_msg_list && messages_are_new) {
|
||||
self._maybe_autoscroll(new_dom_elements, last_message_was_selected);
|
||||
self._maybe_autoscroll(new_dom_elements);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_maybe_autoscroll: function MessageListView__maybe_autoscroll(rendered_elems,
|
||||
last_message_was_selected) {
|
||||
_maybe_autoscroll: function MessageListView__maybe_autoscroll(rendered_elems) {
|
||||
// If we are near the bottom of our feed (the bottom is visible) and can
|
||||
// scroll up without moving the pointer out of the viewport, do so, by
|
||||
// up to the amount taken up by the new message.
|
||||
@ -686,14 +683,6 @@ MessageListView.prototype = {
|
||||
}
|
||||
}, this);
|
||||
|
||||
// autoscroll_forever: if we're on the last message, keep us on the last message
|
||||
if (last_message_was_selected && page_params.autoscroll_forever) {
|
||||
this.list.select_id(this.list.last().id, {from_rendering: true});
|
||||
navigate.scroll_to_selected();
|
||||
this.list.reselect_selected_id();
|
||||
return;
|
||||
}
|
||||
|
||||
var selected_row = this.selected_row();
|
||||
var last_visible = rows.last_visible();
|
||||
|
||||
@ -706,16 +695,6 @@ MessageListView.prototype = {
|
||||
var info = message_viewport.message_viewport_info();
|
||||
var available_space_for_scroll = selected_row_offset - info.visible_top;
|
||||
|
||||
var rows_offset = rows.last_visible().offset().top - this.list.selected_row().offset().top;
|
||||
|
||||
// autoscroll_forever: if we've sent a message, move pointer at least that far.
|
||||
if (page_params.autoscroll_forever && id_of_last_message_sent_by_us > -1 &&
|
||||
rows_offset < (message_viewport.height())) {
|
||||
this.list.select_id(id_of_last_message_sent_by_us, {from_rendering: true});
|
||||
navigate.scroll_to_selected();
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't scroll if we can't move the pointer up.
|
||||
if (available_space_for_scroll <= 0) {
|
||||
return;
|
||||
|
||||
@ -495,10 +495,7 @@ exports.received_messages = function (messages) {
|
||||
if (!message_is_notifiable(message)) {
|
||||
return;
|
||||
}
|
||||
// checking for unread flags here is basically proxy for
|
||||
// "is Zulip currently in focus". In the case of auto-scroll forever,
|
||||
// we don't care
|
||||
if (!unread.message_unread(message) && !page_params.autoscroll_forever) {
|
||||
if (!unread.message_unread(message)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -203,9 +203,7 @@ exports.watch_manual_resize = function (element) {
|
||||
};
|
||||
|
||||
exports.resize_bottom_whitespace = function (h) {
|
||||
if (page_params.autoscroll_forever) {
|
||||
$("#bottom_whitespace").height($("#compose-container")[0].offsetHeight);
|
||||
} else if (h !== undefined) {
|
||||
if (h !== undefined) {
|
||||
$("#bottom_whitespace").height(h.bottom_whitespace_height);
|
||||
}
|
||||
};
|
||||
|
||||
@ -8,7 +8,7 @@ exports.set_up = function () {
|
||||
$("#ui-settings .change-setting").change(function (e) {
|
||||
e.preventDefault();
|
||||
var labs_updates = {};
|
||||
_.each(["autoscroll_forever", "default_desktop_notifications"],
|
||||
_.each(["default_desktop_notifications"],
|
||||
function (setting) {
|
||||
labs_updates[setting] = $("#" + setting).is(":checked");
|
||||
});
|
||||
@ -16,16 +16,10 @@ exports.set_up = function () {
|
||||
channel.patch({
|
||||
url: '/json/settings/ui',
|
||||
data: labs_updates,
|
||||
success: function (resp, statusText, xhr) {
|
||||
success: function () {
|
||||
var message = i18n.t("Updated settings! You will need to reload for these changes to take effect.", page_params);
|
||||
var result = JSON.parse(xhr.responseText);
|
||||
var ui_settings_status = $('#ui-settings-status').expectOne();
|
||||
|
||||
if (result.autoscroll_forever !== undefined) {
|
||||
page_params.autoscroll_forever = result.autoscroll_forever;
|
||||
resize.resize_page_components();
|
||||
}
|
||||
|
||||
ui_report.success(message, ui_settings_status);
|
||||
},
|
||||
error: function (xhr) {
|
||||
|
||||
@ -6,18 +6,6 @@
|
||||
<h3 class="light">{{t "UI Settings"}}</h3>
|
||||
|
||||
<div class="side-padded-container">
|
||||
<div class="input-group">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" class="inline-block change-setting" name="autoscroll_forever" id="autoscroll_forever"
|
||||
{{#if page_params.autoscroll_forever}}
|
||||
checked="checked"
|
||||
{{/if}} />
|
||||
<span></span>
|
||||
</label>
|
||||
<label for="autoscroll_forever" class="inline-block">
|
||||
{{t "Always auto-scroll to new messages" }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" class="inline-block change-setting" name="default_desktop_notifications" id="default_desktop_notifications"
|
||||
|
||||
@ -2888,16 +2888,6 @@ def do_change_notification_settings(user_profile: UserProfile, name: str, value:
|
||||
log_event(event)
|
||||
send_event(event, [user_profile.id])
|
||||
|
||||
def do_change_autoscroll_forever(user_profile: UserProfile, autoscroll_forever: bool,
|
||||
log: bool=True) -> None:
|
||||
user_profile.autoscroll_forever = autoscroll_forever
|
||||
user_profile.save(update_fields=["autoscroll_forever"])
|
||||
|
||||
if log:
|
||||
log_event({'type': 'autoscroll_forever',
|
||||
'user': user_profile.email,
|
||||
'autoscroll_forever': autoscroll_forever})
|
||||
|
||||
def do_change_enter_sends(user_profile: UserProfile, enter_sends: bool) -> None:
|
||||
user_profile.enter_sends = enter_sends
|
||||
user_profile.save(update_fields=["enter_sends"])
|
||||
|
||||
@ -247,7 +247,6 @@ def fetch_initial_state_data(user_profile: UserProfile,
|
||||
for prop in UserProfile.property_types:
|
||||
state[prop] = getattr(user_profile, prop)
|
||||
state['emojiset_choices'] = user_profile.emojiset_choices()
|
||||
state['autoscroll_forever'] = user_profile.autoscroll_forever
|
||||
|
||||
if want('update_global_notifications'):
|
||||
for notification in UserProfile.notification_setting_types:
|
||||
|
||||
@ -80,7 +80,6 @@ def users_to_zerver_userprofile(slack_dir: str, realm_id: int, timestamp: Any,
|
||||
avatar_source=avatar_source,
|
||||
is_bot=user.get('is_bot', False),
|
||||
avatar_version=1,
|
||||
autoscroll_forever=False,
|
||||
default_desktop_notifications=True,
|
||||
timezone=timezone,
|
||||
default_sending_stream=None,
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.6 on 2017-12-27 17:55
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('zerver', '0128_scheduledemail_realm'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='userprofile',
|
||||
name='autoscroll_forever',
|
||||
),
|
||||
]
|
||||
@ -576,7 +576,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
|
||||
|
||||
# UI vars
|
||||
enter_sends = models.NullBooleanField(default=False) # type: Optional[bool]
|
||||
autoscroll_forever = models.BooleanField(default=False) # type: bool
|
||||
left_side_userlist = models.BooleanField(default=False) # type: bool
|
||||
emoji_alt_code = models.BooleanField(default=False) # type: bool
|
||||
|
||||
|
||||
@ -44,7 +44,6 @@ class HomeTest(ZulipTestCase):
|
||||
expected_keys = [
|
||||
"alert_words",
|
||||
"attachments",
|
||||
"autoscroll_forever",
|
||||
"avatar_source",
|
||||
"avatar_url",
|
||||
"avatar_url_medium",
|
||||
|
||||
@ -121,7 +121,6 @@ class ChangeSettingsTest(ZulipTestCase):
|
||||
notification_setting)
|
||||
|
||||
def test_ui_settings(self) -> None:
|
||||
self.check_for_toggle_param_patch("/json/settings/ui", "autoscroll_forever")
|
||||
self.check_for_toggle_param_patch("/json/settings/ui", "default_desktop_notifications")
|
||||
|
||||
def test_toggling_boolean_user_display_settings(self) -> None:
|
||||
|
||||
@ -9,12 +9,11 @@ from django.urls import reverse
|
||||
|
||||
from zerver.decorator import has_request_variables, \
|
||||
zulip_login_required, REQ, human_users_only
|
||||
from zerver.lib.actions import do_change_password, \
|
||||
do_change_enter_sends, do_change_notification_settings, \
|
||||
do_change_default_desktop_notifications, do_change_autoscroll_forever, \
|
||||
do_regenerate_api_key, do_change_avatar_fields, do_set_user_display_setting, \
|
||||
validate_email, do_change_user_email, do_start_email_change_process, \
|
||||
check_change_full_name
|
||||
from zerver.lib.actions import do_change_password, do_change_notification_settings, \
|
||||
do_change_enter_sends, do_change_default_desktop_notifications, \
|
||||
do_regenerate_api_key, do_change_avatar_fields, \
|
||||
do_set_user_display_setting, validate_email, do_change_user_email, \
|
||||
do_start_email_change_process, check_change_full_name
|
||||
from zerver.lib.avatar import avatar_url
|
||||
from zerver.lib.send_email import send_email, FromAddress
|
||||
from zerver.lib.i18n import get_available_language_codes
|
||||
@ -57,16 +56,10 @@ def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpRes
|
||||
@has_request_variables
|
||||
def json_change_ui_settings(
|
||||
request: HttpRequest, user_profile: UserProfile,
|
||||
autoscroll_forever: Optional[bool]=REQ(validator=check_bool, default=None),
|
||||
default_desktop_notifications: Optional[bool]=REQ(validator=check_bool, default=None)
|
||||
) -> HttpResponse:
|
||||
result = {}
|
||||
|
||||
if autoscroll_forever is not None and \
|
||||
user_profile.autoscroll_forever != autoscroll_forever:
|
||||
do_change_autoscroll_forever(user_profile, autoscroll_forever)
|
||||
result['autoscroll_forever'] = autoscroll_forever
|
||||
|
||||
if default_desktop_notifications is not None and \
|
||||
user_profile.default_desktop_notifications != default_desktop_notifications:
|
||||
do_change_default_desktop_notifications(user_profile, default_desktop_notifications)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user